Skip to content

Commit

Permalink
Merge pull request #329 from BT-dmoreno/17.0-mig-product_variant_conf…
Browse files Browse the repository at this point in the history
…igurator

[MIG] Make product variant form view look prettier.
  • Loading branch information
BT-dmoreno authored May 6, 2024
2 parents 5052426 + 0ee5f8d commit 9da795e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
28 changes: 21 additions & 7 deletions product_variant_configurator/models/pricelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,27 @@
class ProductPricelist(models.Model):
_inherit = "product.pricelist"

def _compute_price_rule(self, products, qty, uom=None, date=False, **kwargs):
"""Overwrite for covering the case where templates are passed and a
different uom is used."""
def _compute_price_rule(
self,
products,
quantity,
currency=None,
uom=None,
date=False,
compute_price=True,
**kwargs,
):
"""Overwrite for covering the case where templates are passed and a different uom is used."""
if products[0]._name != "product.template":
# Standard use case - Nothing to do
return super()._compute_price_rule(
products,
qty,
date=date,
quantity,
currency=currency,
uom=uom,
date=date,
compute_price=compute_price,
**kwargs,
)
# Isolate object
pricelist_obj = self
Expand All @@ -31,9 +42,12 @@ def _compute_price_rule(self, products, qty, uom=None, date=False, **kwargs):

return super(ProductPricelist, pricelist_obj)._compute_price_rule(
products,
qty,
quantity,
currency=currency,
uom=uom,
date=date,
uom=False,
compute_price=compute_price,
**kwargs,
)

def template_price_get(self, prod_id, qty, partner=None):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,14 @@
<field name="inherit_id" ref="product.product_normal_form_view" />
<field name="arch" type="xml">
<field name="name" position="attributes">
<attribute
name="invisible"
>id != False or product_tmpl_id != False</attribute>
<attribute name="readonly">product_tmpl_id != False</attribute>
<attribute name="readonly">product_tmpl_id</attribute>
</field>
<field name="product_tmpl_id" position="attributes">
<attribute name="placeholder">Product Template</attribute>
<attribute name="invisible">0</attribute>
<attribute name="readonly">0</attribute>
<attribute name="readonly">id != False</attribute>
<attribute name="required">id != False</attribute>
<attribute name="readonly">id</attribute>
</field>
<xpath expr="//field[@name='product_tmpl_id']/.." position="after">
<p class="oe_grey" invisible="id != False">
<xpath expr="//div[hasclass('oe_title')]" position="after">
<field name="product_tmpl_id" placeholder="Product Template" />
<p class="oe_grey" invisible="id">
Select a template for a variant. Keep empty for a new full product.
</p>
</xpath>
Expand Down

0 comments on commit 9da795e

Please sign in to comment.