Browse Source

fix display unit, add seller id, fix xml

pull/9/head
gregoire 9 years ago
parent
commit
a328bb9feb
  1. 14
      beesdoo_product/models/beesdoo_product.py
  2. 33
      beesdoo_product/views/beesdoo_product.xml

14
beesdoo_product/models/beesdoo_product.py

@ -19,11 +19,14 @@ class BeesdooProduct(models.Model):
total_with_vat_by_unit = fields.Float(compute='get_total_with_vat_by_unit') total_with_vat_by_unit = fields.Float(compute='get_total_with_vat_by_unit')
main_seller_id = fields.Many2one('res.partner', compute='_compute_main_seller_id', store=True)
@api.one @api.one
@api.depends('weight', 'display_unit') @api.depends('weight', 'display_unit')
def get_display_weight(self): def get_display_weight(self):
if self.display_unit: if self.display_unit:
self.display_weight = self.weight / self.display_unit.factor
self.display_weight = self.weight * self.display_unit.factor
@api.one @api.one
def get_total_with_vat(self): def get_total_with_vat(self):
@ -36,7 +39,14 @@ class BeesdooProduct(models.Model):
@api.one @api.one
def get_total_with_vat_by_unit(self): def get_total_with_vat_by_unit(self):
if self.display_weight > 0: if self.display_weight > 0:
self.total_with_vat_by_unit = self.total_with_vat/self.display_weight
self.total_with_vat_by_unit = self.total_with_vat / self.weight
@api.one
@api.depends('seller_ids', 'seller_ids.date_start')
def _compute_main_seller_id(self):
# Calcule le vendeur associé qui a la date de début la plus récente et plus petite qu’aujourd’hui
sellers_ids = self.seller_ids.sorted(key=lambda seller: seller.date_start, reverse=True)
self.main_seller_id = sellers_ids and sellers_ids[0].name or False
class BeesdooProductLabel(models.Model): class BeesdooProductLabel(models.Model):

33
beesdoo_product/views/beesdoo_product.xml

@ -7,21 +7,28 @@
<field name="arch" type="xml"> <field name="arch" type="xml">
<xpath expr="//group[@name='inventory']/.." position="after"> <xpath expr="//group[@name='inventory']/.." position="after">
<page string="Price tag"> <page string="Price tag">
<group name="label">
<field name="total_with_vat"/>
<field name="total_with_vat_by_unit"/>
<field name="default_reference_unit"/>
<field name="display_weight"/>
</group>
<group>
<field name="eco_label"/>
<field name="local_label"/>
<field name="fair_label"/>
<field name="origin_label"/>
<group name="label" col="4">
<group col="2">
<separator string="Amount" colspan="4"/>
<field name="display_weight"/>
<field name="display_unit"/>
<field name="default_reference_unit"/>
<separator string="Price" colspan="4"/>
<field name="total_with_vat"/>
<field name="total_with_vat_by_unit"/>
</group>
<group col="2">
<separator string="Bobo-level" colspan="4"/>
<field name="eco_label"/>
<field name="local_label"/>
<field name="fair_label"/>
<field name="origin_label"/>
<separator string="Origin" colspan="4"/>
<field name="main_seller_id"/>
</group>
</group> </group>
</page> </page>
</xpath> </xpath>
</field> </field>
</record> </record>
</odoo>
</odoo>
Loading…
Cancel
Save