Skip to content

Commit

Permalink
[16.0][FIX] pre-commit
Browse files Browse the repository at this point in the history
[16.0][FIX] product variant view

[16.0][FIX] add unique sql constaint for ecotaxe classif on product
  • Loading branch information
mourad-ehm committed Mar 4, 2024
1 parent 5248178 commit cd691c9
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 9 deletions.
13 changes: 13 additions & 0 deletions l10n_fr_ecotaxe/models/ecotaxe_line_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,16 @@ def _compute_ecotaxe(self):
if ecotaxeline.force_ecotaxe_amount:
amt = ecotaxeline.force_ecotaxe_amount
ecotaxeline.ecotaxe_amount = amt

_sql_constraints = [
(
"unique_ecotaxe_classification_id_by_product",
"UNIQUE(ecotaxe_classification_id, product_id)",
"Only one ecotaxe classification occurrence by product",
),
(
"unique_ecotaxe_classification_id_by_product_tmpl",
"UNIQUE(ecotaxe_classification_id, product_tmplt_id)",
"Only one ecotaxe classification occurrence by product Template",
),
]
35 changes: 28 additions & 7 deletions l10n_fr_ecotaxe/views/account_move_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@
expr="//field[@name='invoice_line_ids']/tree/field[@name='tax_ids']"
position="after"
>
<field name="subtotal_ecotaxe" optional="show" attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]}"/>
<field name="ecotaxe_amount_unit" optional="hide" attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]}"/>
<field
name="subtotal_ecotaxe"
optional="show"
attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]}"
/>
<field
name="ecotaxe_amount_unit"
optional="hide"
attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]}"
/>
</xpath>
<xpath
expr="//field[@name='invoice_line_ids']/tree/field[last()]"
Expand All @@ -39,20 +47,33 @@
expr="//field[@name='invoice_line_ids']/form/sheet/field[@name='name']"
position="after"
>
<field name="ecotaxe_line_ids" colspan="2" attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]}">
<field
name="ecotaxe_line_ids"
colspan="2"
attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]}"
>
<tree editable="bottom">
<field name="ecotaxe_classification_id" />
<field name="force_ecotaxe_unit" />
<field name="ecotaxe_amount_unit" />
<field name="ecotaxe_amount_total" />
</tree>
</field>
<field name="subtotal_ecotaxe" attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]}"/>
<field name="ecotaxe_amount_unit" attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]}"/>
<field
name="subtotal_ecotaxe"
attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]}"
/>
<field
name="ecotaxe_amount_unit"
attrs="{'invisible': [('parent.move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt'))]}"
/>
</xpath>
<xpath expr="//field[@name='tax_totals']" position="after">
<field name="amount_ecotaxe" class="oe_subtotal_footer_separator"
attrs="{'invisible': [ '|', ('move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt')), ('amount_ecotaxe', '=', 0)]}"/>
<field
name="amount_ecotaxe"
class="oe_subtotal_footer_separator"
attrs="{'invisible': [ '|', ('move_type', 'not in', ('out_invoice', 'out_refund', 'out_receipt')), ('amount_ecotaxe', '=', 0)]}"
/>
</xpath>
</field>
</record>
Expand Down
5 changes: 4 additions & 1 deletion l10n_fr_ecotaxe/views/product_template_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
<field name="arch" type="xml">

<xpath expr="//label[@for='list_price']" position="before">
<label for="ecotaxe_line_product_ids" string="Ecotaxe classification" />
<label
for="ecotaxe_line_product_ids"
string="Product Template Ecotaxe classif"
/>
<div>
<field name="ecotaxe_line_product_ids" colspan="2" nolabel="1">
<tree editable="bottom">
Expand Down
27 changes: 26 additions & 1 deletion l10n_fr_ecotaxe/views/product_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,30 @@
</group>
</field>
</record>

<record id="product_normal_form_view" model="ir.ui.view">
<field name="name">usability.product.product.form</field>
<field name="model">product.product</field>
<field name="inherit_id" ref="product.product_normal_form_view" />
<field name="arch" type="xml">
<xpath expr="//field[@name='ecotaxe_line_product_ids']/.." position="after">
<label
for="additional_ecotaxe_line_product_ids"
string="Additional Ecotaxe classif"
/>
<div>
<field
name="additional_ecotaxe_line_product_ids"
colspan="2"
nolabel="1"
>
<tree editable="bottom">
<field name="ecotaxe_classification_id" />
<field name="force_ecotaxe_amount" />
<field name="ecotaxe_amount" />
</tree>
</field>
</div>
</xpath>
</field>
</record>
</odoo>

0 comments on commit cd691c9

Please sign in to comment.