diff --git a/l10n_br_delivery/__manifest__.py b/l10n_br_delivery/__manifest__.py index 5e5af0254ec1..f247791cc03d 100644 --- a/l10n_br_delivery/__manifest__.py +++ b/l10n_br_delivery/__manifest__.py @@ -8,7 +8,7 @@ standards.""", 'license': 'AGPL-3', 'author': 'Akretion, Odoo Community Association (OCA)', - 'website': 'https://github.com/oca/l10n-brazil', + 'website': 'https://github.com/OCA/l10n-brazil', 'version': '12.0.3.0.0', 'depends': [ 'l10n_br_account', diff --git a/l10n_br_sale/models/res_company.py b/l10n_br_sale/models/res_company.py index b663b1d7cb54..93e29fe89871 100644 --- a/l10n_br_sale/models/res_company.py +++ b/l10n_br_sale/models/res_company.py @@ -18,12 +18,9 @@ class Company(models.Model): ) delivery_costs = fields.Selection( - selection=[ - ('line', _('By Line')), - ('total', _('By Total')) - ], - string='Delivery costs should be define in Line or Total.', - help='Define if costs of Insurance, Freight and Other Costs' - ' should be informed in Line or Total.', - default='total' + selection=[("line", _("By Line")), ("total", _("By Total"))], + string="Delivery costs should be define in Line or Total.", + help="Define if costs of Insurance, Freight and Other Costs" + " should be informed in Line or Total.", + default="total", ) diff --git a/l10n_br_sale/models/res_config_settings.py b/l10n_br_sale/models/res_config_settings.py index 988a96400c10..45f7cd11e6b0 100644 --- a/l10n_br_sale/models/res_config_settings.py +++ b/l10n_br_sale/models/res_config_settings.py @@ -14,6 +14,5 @@ class ResConfigSettings(models.TransientModel): ) delivery_costs = fields.Selection( - related='company_id.delivery_costs', - readonly=False + related="company_id.delivery_costs", readonly=False ) diff --git a/l10n_br_sale/models/sale_order.py b/l10n_br_sale/models/sale_order.py index 7ccf234367dd..daf4e997a91e 100644 --- a/l10n_br_sale/models/sale_order.py +++ b/l10n_br_sale/models/sale_order.py @@ -76,131 +76,132 @@ def _fiscal_operation_domain(self): ) amount_freight_value = fields.Monetary( - inverse='_inverse_amount_freight', + inverse="_inverse_amount_freight", ) amount_insurance_value = fields.Monetary( - inverse='_inverse_amount_insurance', + inverse="_inverse_amount_insurance", ) amount_other_value = fields.Monetary( - inverse='_inverse_amount_other', + inverse="_inverse_amount_other", ) # Usado para tornar Somente Leitura os campos totais dos custos # de entrega quando a definição for por Linha delivery_costs = fields.Selection( - related='company_id.delivery_costs', + related="company_id.delivery_costs", ) - @api.multi def _inverse_amount_freight(self): for record in self.filtered(lambda so: so.order_line): - if record.company_id.delivery_costs == 'total': + if record.company_id.delivery_costs == "total": amount_freight_value = record.amount_freight_value - if all(record.order_line.mapped('freight_value')): - amount_freight_old = sum( - record.order_line.mapped('freight_value')) + if all(record.order_line.mapped("freight_value")): + amount_freight_old = sum(record.order_line.mapped("freight_value")) for line in record.order_line[:-1]: line.freight_value = amount_freight_value * ( - line.freight_value / amount_freight_old) - record.order_line[-1].freight_value = ( - amount_freight_value - - sum(line.freight_value - for line in record.order_line[:-1]) + line.freight_value / amount_freight_old + ) + record.order_line[-1].freight_value = amount_freight_value - sum( + line.freight_value for line in record.order_line[:-1] ) else: - amount_total = sum(record.order_line.mapped('price_total')) + amount_total = sum(record.order_line.mapped("price_total")) for line in record.order_line[:-1]: line.freight_value = amount_freight_value * ( - line.price_total / amount_total) - record.order_line[-1].freight_value = ( - amount_freight_value - - sum(line.freight_value - for line in record.order_line[:-1]) + line.price_total / amount_total + ) + record.order_line[-1].freight_value = amount_freight_value - sum( + line.freight_value for line in record.order_line[:-1] ) for line in record.order_line: line._onchange_fiscal_taxes() - record._fields['amount_total'].compute_value(record) - record.write({ - name: value - for name, value in record._cache.items() - if record._fields[name].compute == '_amount_all' and - not record._fields[name].inverse - }) + record._fields["amount_total"].compute_value(record) + record.write( + { + name: value + for name, value in record._cache.items() + if record._fields[name].compute == "_amount_all" + and not record._fields[name].inverse + } + ) - @api.multi def _inverse_amount_insurance(self): for record in self.filtered(lambda so: so.order_line): - if record.company_id.delivery_costs == 'total': + if record.company_id.delivery_costs == "total": amount_insurance_value = record.amount_insurance_value - if all(record.order_line.mapped('insurance_value')): + if all(record.order_line.mapped("insurance_value")): amount_insurance_old = sum( - record.order_line.mapped('insurance_value')) + record.order_line.mapped("insurance_value") + ) for line in record.order_line[:-1]: line.insurance_value = amount_insurance_value * ( - line.insurance_value / amount_insurance_old) - record.order_line[-1].insurance_value = \ - amount_insurance_value - sum( - line.insurance_value - for line in record.order_line[:-1] + line.insurance_value / amount_insurance_old ) + record.order_line[ + -1 + ].insurance_value = amount_insurance_value - sum( + line.insurance_value for line in record.order_line[:-1] + ) else: - amount_total = sum(record.order_line.mapped('price_total')) + amount_total = sum(record.order_line.mapped("price_total")) for line in record.order_line[:-1]: line.insurance_value = amount_insurance_value * ( - line.price_total / amount_total) - record.order_line[-1].insurance_value = \ - amount_insurance_value - sum( - line.insurance_value - for line in record.order_line[:-1]) + line.price_total / amount_total + ) + record.order_line[ + -1 + ].insurance_value = amount_insurance_value - sum( + line.insurance_value for line in record.order_line[:-1] + ) for line in record.order_line: line._onchange_fiscal_taxes() - record._fields['amount_total'].compute_value(record) - record.write({ - name: value - for name, value in record._cache.items() - if record._fields[name].compute == '_amount_all' and - not record._fields[name].inverse - }) + record._fields["amount_total"].compute_value(record) + record.write( + { + name: value + for name, value in record._cache.items() + if record._fields[name].compute == "_amount_all" + and not record._fields[name].inverse + } + ) - @api.multi def _inverse_amount_other(self): for record in self.filtered(lambda so: so.order_line): - if record.company_id.delivery_costs == 'total': + if record.company_id.delivery_costs == "total": amount_other_value = record.amount_other_value - if all(record.order_line.mapped('other_value')): - amount_other_old = sum( - record.order_line.mapped('other_value')) + if all(record.order_line.mapped("other_value")): + amount_other_old = sum(record.order_line.mapped("other_value")) for line in record.order_line[:-1]: line.other_value = amount_other_value * ( - line.other_value / amount_other_old) - record.order_line[-1].other_value = ( - amount_other_value - - sum(line.other_value - for line in record.order_line[:-1]) + line.other_value / amount_other_old + ) + record.order_line[-1].other_value = amount_other_value - sum( + line.other_value for line in record.order_line[:-1] ) else: - amount_total = sum(record.order_line.mapped('price_total')) + amount_total = sum(record.order_line.mapped("price_total")) for line in record.order_line[:-1]: line.other_value = amount_other_value * ( - line.price_total / amount_total) - record.order_line[-1].other_value = ( - amount_other_value - - sum(line.other_value - for line in record.order_line[:-1]) + line.price_total / amount_total + ) + record.order_line[-1].other_value = amount_other_value - sum( + line.other_value for line in record.order_line[:-1] ) for line in record.order_line: line._onchange_fiscal_taxes() - record._fields['amount_total'].compute_value(record) - record.write({ - name: value - for name, value in record._cache.items() - if record._fields[name].compute == '_amount_all' and - not record._fields[name].inverse - }) + record._fields["amount_total"].compute_value(record) + record.write( + { + name: value + for name, value in record._cache.items() + if record._fields[name].compute == "_amount_all" + and not record._fields[name].inverse + } + ) @api.multi def _get_amount_lines(self): diff --git a/l10n_br_sale/models/sale_order_line.py b/l10n_br_sale/models/sale_order_line.py index c6039758e37f..68596b763194 100644 --- a/l10n_br_sale/models/sale_order_line.py +++ b/l10n_br_sale/models/sale_order_line.py @@ -95,7 +95,7 @@ def _fiscal_operation_domain(self): # Usado para tornar Somente Leitura os campos dos custos # de entrega quando a definição for por Total delivery_costs = fields.Selection( - related='company_id.delivery_costs', + related="company_id.delivery_costs", ) def _get_protected_fields(self): diff --git a/l10n_br_sale/views/res_company_view.xml b/l10n_br_sale/views/res_company_view.xml index b1b4ad9685d0..084128dfc1d2 100644 --- a/l10n_br_sale/views/res_company_view.xml +++ b/l10n_br_sale/views/res_company_view.xml @@ -12,10 +12,7 @@ - - - - + diff --git a/l10n_br_sale/views/res_config_settings_view.xml b/l10n_br_sale/views/res_config_settings_view.xml index 212e6a844823..5bdc98c099b6 100644 --- a/l10n_br_sale/views/res_config_settings_view.xml +++ b/l10n_br_sale/views/res_config_settings_view.xml @@ -18,17 +18,23 @@ -
+
-
diff --git a/l10n_br_sale/views/sale_view.xml b/l10n_br_sale/views/sale_view.xml index 6b0eb98be321..791792224922 100644 --- a/l10n_br_sale/views/sale_view.xml +++ b/l10n_br_sale/views/sale_view.xml @@ -35,7 +35,7 @@ /> - + - + + name="freight_value" + attrs="{'readonly': [('delivery_costs', '=', 'total')]}" + /> + name="insurance_value" + attrs="{'readonly': [('delivery_costs', '=', 'total')]}" + /> + name="other_value" + attrs="{'readonly': [('delivery_costs', '=', 'total')]}" + />