[PATCH] Upstream patch - 08032022

This commit is contained in:
Parthiv Patel
2022-03-08 08:36:06 +00:00
parent 7773cd18a0
commit e4ac36a988
16 changed files with 199 additions and 42 deletions

View File

@@ -585,7 +585,7 @@ class AccountBankStatementLine(models.Model):
statement = self.statement_id
journal = statement.journal_id
company_currency = journal.company_id.currency_id
journal_currency = journal.currency_id if journal.currency_id != company_currency else False
journal_currency = journal.currency_id or company_currency
if self.foreign_currency_id and journal_currency:
currency_id = journal_currency.id

View File

@@ -140,6 +140,10 @@ class AccountTax(models.Model):
if len(invoice_repartition_line_ids) != len(refund_repartition_line_ids):
raise ValidationError(_("Invoice and credit note distribution should have the same number of lines."))
if not invoice_repartition_line_ids.filtered(lambda x: x.repartition_type == 'tax') or \
not refund_repartition_line_ids.filtered(lambda x: x.repartition_type == 'tax'):
raise ValidationError(_("Invoice and credit note repartition should have at least one tax repartition line."))
index = 0
while index < len(invoice_repartition_line_ids):
inv_rep_ln = invoice_repartition_line_ids[index]

View File

@@ -334,11 +334,11 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
cls.expected_bank_line = {
'name': cls.statement_line.payment_ref,
'partner_id': cls.statement_line.partner_id.id,
'currency_id': cls.currency_2.id,
'currency_id': cls.currency_1.id,
'account_id': cls.statement.journal_id.default_account_id.id,
'debit': 1250.0,
'credit': 0.0,
'amount_currency': 2500.0,
'amount_currency': 1250.0,
}
cls.expected_counterpart_line = {
@@ -515,7 +515,7 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
self._test_edition_customer_and_supplier_flows(
80.0, 120.0,
self.currency_1, self.currency_2,
{'debit': 80.0, 'credit': 0.0, 'amount_currency': 120.0, 'currency_id': self.currency_2.id},
{'debit': 80.0, 'credit': 0.0, 'amount_currency': 80.0, 'currency_id': self.currency_1.id},
{'debit': 0.0, 'credit': 80.0, 'amount_currency': -120.0, 'currency_id': self.currency_2.id},
)
@@ -555,7 +555,7 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
})
self.assertRecordValues(statement.line_ids.move_id.line_ids, [
{'debit': 0.0, 'credit': 0.0, 'amount_currency': 10.0, 'currency_id': self.currency_2.id},
{'debit': 0.0, 'credit': 0.0, 'amount_currency': 0.0, 'currency_id': self.currency_1.id},
{'debit': 0.0, 'credit': 0.0, 'amount_currency': -10.0, 'currency_id': self.currency_2.id},
])
@@ -579,7 +579,7 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
})
self.assertRecordValues(statement.line_ids.move_id.line_ids, [
{'debit': 10.0, 'credit': 0.0, 'amount_currency': 0.0, 'currency_id': self.currency_2.id},
{'debit': 10.0, 'credit': 0.0, 'amount_currency': 10.0, 'currency_id': self.currency_1.id},
{'debit': 0.0, 'credit': 10.0, 'amount_currency': 0.0, 'currency_id': self.currency_2.id},
])
@@ -775,8 +775,8 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
**self.expected_bank_line,
'debit': 0.0,
'credit': 2000.0,
'amount_currency': -4000.0,
'currency_id': self.currency_3.id,
'amount_currency': -2000.0,
'currency_id': self.currency_1.id,
},
{
**self.expected_counterpart_line,
@@ -807,8 +807,8 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
'partner_id': self.statement_line.partner_id.id,
'debit': 0.0,
'credit': 2000.0,
'amount_currency': -4000.0,
'currency_id': self.currency_3.id,
'amount_currency': -2000.0,
'currency_id': self.currency_1.id,
},
{
**self.expected_counterpart_line,
@@ -1059,7 +1059,7 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
self._test_reconciliation_customer_and_supplier_flows(
80.0, 120.0, -120.0,
self.currency_1, self.currency_2, self.currency_2,
{'debit': 80.0, 'credit': 0.0, 'amount_currency': 120.0, 'currency_id': self.currency_2.id},
{'debit': 80.0, 'credit': 0.0, 'amount_currency': 80.0, 'currency_id': self.currency_1.id},
{'debit': 0.0, 'credit': 80.0, 'amount_currency': -120.0, 'currency_id': self.currency_2.id},
)
@@ -1067,7 +1067,7 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
self._test_reconciliation_customer_and_supplier_flows(
80.0, 120.0, -480.0,
self.currency_1, self.currency_2, self.currency_3,
{'debit': 80.0, 'credit': 0.0, 'amount_currency': 120.0, 'currency_id': self.currency_2.id},
{'debit': 80.0, 'credit': 0.0, 'amount_currency': 80.0, 'currency_id': self.currency_1.id},
{'debit': 0.0, 'credit': 80.0, 'amount_currency': -120.0, 'currency_id': self.currency_2.id},
)
@@ -1115,7 +1115,7 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
self._test_reconciliation_customer_and_supplier_flows(
80.0, 120.0, -80.0,
self.currency_1, self.currency_2, self.currency_1,
{'debit': 80.0, 'credit': 0.0, 'amount_currency': 120.0, 'currency_id': self.currency_2.id},
{'debit': 80.0, 'credit': 0.0, 'amount_currency': 80.0, 'currency_id': self.currency_1.id},
{'debit': 0.0, 'credit': 80.0, 'amount_currency': -120.0, 'currency_id': self.currency_2.id},
)
@@ -1267,7 +1267,7 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
{
**self.expected_bank_line,
'amount_residual': 1250.0,
'amount_residual_currency': 2500.0,
'amount_residual_currency': 1250.0,
},
])
@@ -1309,7 +1309,7 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
{
**self.expected_bank_line,
'amount_residual': 1250.0,
'amount_residual_currency': 2500.0,
'amount_residual_currency': 1250.0,
},
])
@@ -1347,7 +1347,7 @@ class TestAccountBankStatementLine(TestAccountBankStatementCommon):
{
**self.expected_bank_line,
'amount_residual': 1250.0,
'amount_residual_currency': 2500.0,
'amount_residual_currency': 1250.0,
},
])

View File

@@ -878,6 +878,8 @@
<field name="account_internal_type" invisible="1"/>
<field name="account_internal_group" invisible="1"/>
</kanban>
<!-- Form view to cover mobile use -->
<form>
<sheet>
<field name="product_uom_category_id" invisible="1"/>
@@ -886,6 +888,8 @@
<group>
<field name="partner_id" invisible="1"/>
<field name="company_id" invisible="1"/>
<field name="debit" invisible="1"/>
<field name="credit" invisible="1"/>
<field name="product_id" widget="many2one_barcode"/>
<field name="quantity"/>
<field name="product_uom_id" groups="uom.group_uom"/>
@@ -903,6 +907,10 @@
<label for="name" string="Section" attrs="{'invisible': [('display_type', '!=', 'line_section')]}"/>
<label for="name" string="Note" attrs="{'invisible': [('display_type', '!=', 'line_note')]}"/>
<field name="name" widget="text"/>
<group>
<field name="price_subtotal" string="Subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<field name="price_total" string="Total" groups="account.group_show_line_subtotals_tax_included"/>
</group>
</sheet>
</form>
</field>

View File

@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
from flectra import models, fields, api
from flectra import models, fields, api, _
from flectra.addons.account_edi_extended.models.account_edi_document import DEFAULT_BLOCKING_LEVEL
from flectra.exceptions import UserError
from psycopg2 import OperationalError
import base64
import logging
@@ -265,12 +267,15 @@ class AccountEdiDocument(models.Model):
if attachments_potential_unlink:
self._cr.execute('SELECT * FROM ir_attachment WHERE id IN %s FOR UPDATE NOWAIT', [tuple(attachments_potential_unlink.ids)])
self._process_job(documents, doc_type)
except OperationalError as e:
if e.pgcode == '55P03':
_logger.debug('Another transaction already locked documents rows. Cannot process documents.')
if not with_commit:
raise UserError(_('This document is being sent by another process already. '))
continue
else:
raise e
else:
if with_commit and len(jobs) > 1:
self.env.cr.commit()
self._process_job(documents, doc_type)
if with_commit and len(jobs) > 1:
self.env.cr.commit()

View File

@@ -60,15 +60,28 @@ class ProviderGrid(models.Model):
'price': 0.0,
'error_message': e.args[0],
'warning_message': False}
if order.company_id.currency_id.id != order.pricelist_id.currency_id.id:
price_unit = order.company_id.currency_id._convert(
price_unit, order.pricelist_id.currency_id, order.company_id, order.date_order or fields.Date.today())
price_unit = self._compute_currency(order, price_unit, 'company_to_pricelist')
return {'success': True,
'price': price_unit,
'error_message': False,
'warning_message': False}
def _get_conversion_currencies(self, order, conversion):
if conversion == 'company_to_pricelist':
from_currency, to_currency = order.company_id.currency_id, order.pricelist_id.currency_id
elif conversion == 'pricelist_to_company':
from_currency, to_currency = order.currency_id, order.company_id.currency_id
return from_currency, to_currency
def _compute_currency(self, order, price, conversion):
from_currency, to_currency = self._get_conversion_currencies(order, conversion)
if from_currency.id == to_currency.id:
return price
return from_currency._convert(price, to_currency, order.company_id, order.date_order or fields.Date.today())
def _get_price_available(self, order):
self.ensure_one()
self = self.sudo()
@@ -90,8 +103,7 @@ class ProviderGrid(models.Model):
quantity += qty
total = (order.amount_total or 0.0) - total_delivery
total = order.currency_id._convert(
total, order.company_id.currency_id, order.company_id, order.date_order or fields.Date.today())
total = self._compute_currency(order, total, 'pricelist_to_company')
return self._get_price_from_picking(total, weight, volume, quantity)

View File

@@ -132,6 +132,22 @@ class AccountMove(models.Model):
if not rec.l10n_ar_afip_service_end:
rec.l10n_ar_afip_service_end = rec.invoice_date + relativedelta(day=1, days=-1, months=+1)
def _set_afip_responsibility(self):
""" We save the information about the receptor responsability at the time we validate the invoice, this is
necessary because the user can change the responsability after that any time """
for rec in self:
rec.l10n_ar_afip_responsibility_type_id = rec.commercial_partner_id.l10n_ar_afip_responsibility_type_id.id
def _set_afip_rate(self):
""" We set the l10n_ar_currency_rate value with the accounting date. This should be done
after invoice has been posted in order to have the proper accounting date"""
for rec in self:
if rec.company_id.currency_id == rec.currency_id:
rec.l10n_ar_currency_rate = 1.0
elif not rec.l10n_ar_currency_rate:
rec.l10n_ar_currency_rate = rec.currency_id._convert(
1.0, rec.company_id.currency_id, rec.company_id, rec.date, round=False)
@api.onchange('partner_id')
def _onchange_afip_responsibility(self):
if self.company_id.country_id.code == 'AR' and self.l10n_latam_use_documents and self.partner_id \
@@ -168,19 +184,15 @@ class AccountMove(models.Model):
def _post(self, soft=True):
ar_invoices = self.filtered(lambda x: x.company_id.country_id.code == "AR" and x.l10n_latam_use_documents)
for rec in ar_invoices:
rec.l10n_ar_afip_responsibility_type_id = rec.commercial_partner_id.l10n_ar_afip_responsibility_type_id.id
if rec.company_id.currency_id == rec.currency_id:
rec.l10n_ar_currency_rate = 1.0
elif not rec.l10n_ar_currency_rate:
rec.l10n_ar_currency_rate = rec.currency_id._convert(
1.0, rec.company_id.currency_id, rec.company_id, rec.date, round=False)
# We make validations here and not with a constraint because we want validation before sending electronic
# data on l10n_ar_edi
ar_invoices._check_argentinian_invoice_taxes()
posted = super()._post(soft)
posted._set_afip_service_dates()
posted = super()._post(soft=soft)
posted_ar_invoices = posted & ar_invoices
posted_ar_invoices._set_afip_responsibility()
posted_ar_invoices._set_afip_rate()
posted_ar_invoices._set_afip_service_dates()
return posted
def _reverse_moves(self, default_values_list=None, cancel=False):

View File

@@ -845,6 +845,10 @@
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_chtax_900')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -852,6 +856,10 @@
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_chtax_900')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
</record>
@@ -869,6 +877,10 @@
'repartition_type': 'base',
'plus_report_line_ids': [ref('account_tax_report_line_chtax_910')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -876,6 +888,10 @@
'repartition_type': 'base',
'minus_report_line_ids': [ref('account_tax_report_line_chtax_910')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
</record>
</flectra>

View File

@@ -83,6 +83,10 @@
'repartition_type': 'base',
'plus_report_line_ids': [ref('l10n_dk.account_tax_report_line_section_b_product_eu')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -90,6 +94,10 @@
'repartition_type': 'base',
'minus_report_line_ids': [ref('l10n_dk.account_tax_report_line_section_b_product_eu')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
</record>
<record id="tax220" model="account.tax.template">
@@ -105,6 +113,10 @@
'repartition_type': 'base',
'plus_report_line_ids': [ref('l10n_dk.account_tax_report_line_section_b_services')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -112,6 +124,10 @@
'repartition_type': 'base',
'minus_report_line_ids': [ref('l10n_dk.account_tax_report_line_section_b_services')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
</record>
@@ -129,6 +145,10 @@
'repartition_type': 'base',
'plus_report_line_ids': [ref('l10n_dk.account_tax_report_line_section_c')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -136,6 +156,10 @@
'repartition_type': 'base',
'minus_report_line_ids': [ref('l10n_dk.account_tax_report_line_section_c')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
</record>

View File

@@ -564,6 +564,10 @@
'repartition_type': 'base',
'plus_report_line_ids': [ref('tax_report_base_sales_goods_eu')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -571,6 +575,10 @@
'repartition_type': 'base',
'minus_report_line_ids': [ref('tax_report_base_sales_goods_eu')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
</record>
@@ -589,6 +597,10 @@
'repartition_type': 'base',
'plus_report_line_ids': [ref('tax_report_base_sales_service_eu')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -596,6 +608,10 @@
'repartition_type': 'base',
'minus_report_line_ids': [ref('tax_report_base_sales_service_eu')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
</record>
@@ -887,7 +903,10 @@
(0,0, {
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
@@ -895,6 +914,10 @@
'factor_percent': 100,
'repartition_type': 'base',
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
</record>
<record id="triangulation_purchase" model="account.tax.template">
@@ -944,6 +967,10 @@
'repartition_type': 'base',
'plus_report_line_ids': [ref('tax_report_base_sales_construct_service')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -951,6 +978,10 @@
'repartition_type': 'base',
'minus_report_line_ids': [ref('tax_report_base_sales_construct_service')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
</record>
<record id="tax_construct_purchase_24" model="account.tax.template">
@@ -1049,7 +1080,11 @@
'factor_percent': 100,
'repartition_type': 'base',
'plus_report_line_ids': [ref('tax_report_base_turnover_0_vat')],
})
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -1057,6 +1092,10 @@
'repartition_type': 'base',
'minus_report_line_ids': [ref('tax_report_base_turnover_0_vat')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
</record>
@@ -1215,6 +1254,10 @@
'repartition_type': 'base',
'plus_report_line_ids': [ref('tax_report_base_turnover_0_vat')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
<field name="refund_repartition_line_ids" eval="[(5, 0, 0),
(0,0, {
@@ -1222,6 +1265,10 @@
'repartition_type': 'base',
'minus_report_line_ids': [ref('tax_report_base_turnover_0_vat')],
}),
(0,0, {
'factor_percent': 100,
'repartition_type': 'tax',
}),
]"/>
</record>
<record id="import_pay24" model="account.tax.template">

View File

@@ -106,7 +106,7 @@ class Channel(models.Model):
# depends=['...'] is for `test_mail/tests/common.py`, class Moderation, `setUpClass`
channel_last_seen_partner_ids = fields.One2many('mail.channel.partner', 'channel_id', string='Last Seen', depends=['channel_partner_ids'])
channel_partner_ids = fields.Many2many('res.partner', 'mail_channel_partner', 'channel_id', 'partner_id', string='Listeners', depends=['channel_last_seen_partner_ids'])
channel_message_ids = fields.Many2many('mail.message', 'mail_message_mail_channel_rel')
channel_message_ids = fields.Many2many('mail.message', 'mail_message_mail_channel_rel', copy=False)
is_member = fields.Boolean('Is a member', compute='_compute_is_member')
# access
public = fields.Selection([

View File

@@ -91,9 +91,9 @@
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_tree"/>
<field name="arch" type="xml">
<tree string="Contacts">
<field name="category_id" position="after">
<field name="membership_state" optional="hide"/>
</tree>
</field>
</field>
</record>

View File

@@ -237,6 +237,9 @@ class MrpWorkorder(models.Model):
workorder.date_planned_finished = workorder.leave_id.date_to
def _set_dates_planned(self):
if self.leave_id and (not self[0].date_planned_start or not self[0].date_planned_finished):
raise UserError(_("It is not possible to unplan one single Work Order. "
"You should unplan the Manufacturing Order instead in order to unplan all the linked operations."))
date_from = self[0].date_planned_start
date_to = self[0].date_planned_finished
self.mapped('leave_id').sudo().write({

View File

@@ -2,10 +2,20 @@
# Part of Odoo, Flectra. See LICENSE file for full copyright and licensing details.
from datetime import timedelta
import operator as py_operator
from flectra import api, fields, models
from flectra.tools.float_utils import float_round, float_is_zero
OPERATORS = {
'<': py_operator.lt,
'>': py_operator.gt,
'<=': py_operator.le,
'>=': py_operator.ge,
'=': py_operator.eq,
'!=': py_operator.ne
}
class ProductTemplate(models.Model):
_inherit = "product.template"
@@ -221,3 +231,18 @@ class ProductProduct(models.Model):
('move_id.unbuild_id', '!=', False),
])
return super()._count_returned_sn_products(sn_lot) + res
def _search_qty_available_new(self, operator, value, lot_id=False, owner_id=False, package_id=False):
'''extending the method in stock.product to take into account kits'''
product_ids = super(ProductProduct, self)._search_qty_available_new(operator, value, lot_id, owner_id, package_id)
kit_boms = self.env['mrp.bom'].search([('type', "=", 'phantom')])
kit_products = self.env['product.product']
for kit in kit_boms:
if kit.product_id:
kit_products |= kit.product_id
else:
kit_products |= kit.product_tmpl_id.product_variant_ids
for product in kit_products:
if OPERATORS[operator](product.qty_available, value):
product_ids.append(product.id)
return list(set(product_ids))

View File

@@ -10,7 +10,7 @@ class PurchaseRequisition(models.Model):
def _get_picking_in(self):
pick_in = self.env.ref('stock.picking_type_in', raise_if_not_found=False)
company = self.env.company
if not pick_in or pick_in.sudo().warehouse_id.company_id.id != company.id:
if not pick_in or not pick_in.active or pick_in.sudo().warehouse_id.company_id.id != company.id:
pick_in = self.env['stock.picking.type'].search(
[('warehouse_id.company_id', '=', company.id), ('code', '=', 'incoming')],
limit=1,

View File

@@ -564,6 +564,7 @@
widget="many2many_tags"
options="{'no_create': True}"
domain="[('type_tax_use','=','sale'),('company_id','=',parent.company_id)]"
context="{'active_test': True}"
attrs="{'readonly': [('qty_invoiced', '&gt;', 0)]}"
optional="show"
/>