Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MIG] Make product variant form view look prettier. #329

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading