Skip to content

Commit

Permalink
[FIX] Pre commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbcosta committed Jun 10, 2021
1 parent 0dc5db0 commit c73c25d
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 104 deletions.
2 changes: 1 addition & 1 deletion l10n_br_delivery/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
13 changes: 5 additions & 8 deletions l10n_br_sale/models/res_company.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
3 changes: 1 addition & 2 deletions l10n_br_sale/models/res_config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
145 changes: 73 additions & 72 deletions l10n_br_sale/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion l10n_br_sale/models/sale_order_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 1 addition & 4 deletions l10n_br_sale/views/res_company_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
<group>
<field name="sale_fiscal_operation_id" />
<field name="copy_note" />
<field name="delivery_costs"/>
<field name="sale_fiscal_operation_id"/>
<field name="copy_note"/>
<field name="delivery_costs"/>
<field name="delivery_costs" />
</group>
</group>
</page>
Expand Down
16 changes: 11 additions & 5 deletions l10n_br_sale/views/res_config_settings_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,23 @@
</div>
</div>
</div>
<div id="sales_settings_delivery_costs"
class="col-12 col-lg-6 o_setting_box"
title="The Delivery Costs should be informed by Line or by Total ?">
<div
id="sales_settings_delivery_costs"
class="col-12 col-lg-6 o_setting_box"
title="The Delivery Costs should be informed by Line or by Total ?"
>
<div class="o_setting_right_pane">
<label for="delivery_costs"/>
<label for="delivery_costs" />
<div class="text-muted">
Define if Delivery Costs should be informed by Line or by Total
</div>
<div class="content-group">
<div class="mt16">
<field name="delivery_costs" class="o_light_label" widget="radio"/>
<field
name="delivery_costs"
class="o_light_label"
widget="radio"
/>
</div>
</div>
</div>
Expand Down
22 changes: 11 additions & 11 deletions l10n_br_sale/views/sale_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/>
</field>
<field name="amount_untaxed" position="after">
<field name="delivery_costs" invisible="1"/>
<field name="delivery_costs" invisible="1" />
<field
name="amount_freight_value"
widget='monetary'
Expand Down Expand Up @@ -207,19 +207,19 @@
</page>
<page name="others" string="Others">
<group>
<field name="delivery_costs" invisible="1"/>
<field name="delivery_costs" invisible="1" />
<field
name="freight_value"
attrs="{'readonly': [('delivery_costs', '=', 'total')]}"
/>
name="freight_value"
attrs="{'readonly': [('delivery_costs', '=', 'total')]}"
/>
<field
name="insurance_value"
attrs="{'readonly': [('delivery_costs', '=', 'total')]}"
/>
name="insurance_value"
attrs="{'readonly': [('delivery_costs', '=', 'total')]}"
/>
<field
name="other_value"
attrs="{'readonly': [('delivery_costs', '=', 'total')]}"
/>
name="other_value"
attrs="{'readonly': [('delivery_costs', '=', 'total')]}"
/>
</group>
</page>
<page name="fiscal_line_extra_info" string="Extra Info" />
Expand Down

0 comments on commit c73c25d

Please sign in to comment.