Browse Source

add display_weight with an if on the compute method

pull/9/head
gregoire 9 years ago
parent
commit
4809e8a0bd
  1. 26
      beesdoo_product/models/beesdoo_product.py
  2. 8
      beesdoo_product/views/beesdoo_product.xml

26
beesdoo_product/models/beesdoo_product.py

@ -10,33 +10,24 @@ class BeesdooProduct(models.Model):
fair_label = fields.Many2one('beesdoo.product.label', domain=[('type', '=', 'fair')])
origin_label = fields.Many2one('beesdoo.product.label', domain=[('type', '=', 'delivery')])
display_unit = fields.Char()
default_reference_unit = fields.Char()
display_weight = fields.Integer(compute='get_display_weight')
display_unit = fields.Many2one('product.uom', required=True)
default_reference_unit = fields.Many2one('product.uom', required=True)
display_weight = fields.Float(compute='get_display_weight')
total = fields.Float(compute='get_total')
total_with_vat = fields.Float(compute='get_total_with_vat')
@api.one
@api.depends('weight', 'display_unit')
def get_display_weight(self):
pass
if self.display_unit:
self.display_weight = self.weight / self.display_unit.factor
def get_total(self):
price_ht = self.env['product.pricelist'].search([])[0].price_get(self.id, 1)[1]
self.total = price_ht
# grand_total_by_unit = fields.Float(compute='get_grand_total_by_unit')
#
# grand_total = fields.Float(compute='get_grand_total')
#
# def get_grand_total(self):
# self.grand_total = self.env['sale.order.line'] * self.price
#
# def get_grand_total_by_unit(self):
# self.grand_total_by_unit = self.grand_total * self.unit_price
# product.supplierinfo
def get_total_with_vat(self):
tax_amount_sum = 0.0
for tax in self.taxes_id:
@ -44,7 +35,6 @@ class BeesdooProduct(models.Model):
self.total_with_vat = self.total * (100.0 + tax_amount_sum) / 100
class BeesdooProductLabel(models.Model):
_name = 'beesdoo.product.label'

8
beesdoo_product/views/beesdoo_product.xml

@ -52,17 +52,17 @@
<xpath expr="//group[@name='inventory']/.." position="after">
<page string="Étiquette">
<group name="label">
<field name="default_reference_unit"/>
<field name="total"/>
<field name="total_with_vat"/>
<field name="default_reference_unit"/>
</group>
<group>
<field name="display_weight"/>
<field name="eco_label"/>
<field name="local_label"/>
<field name="fair_label"/>
<field name="origin_label"/>
</group>
<group>
<field name="display_weight"/>
</group>
</page>
</xpath>
</field>

Loading…
Cancel
Save