Browse Source

[IMP] add computed field scale_sale_uom

pull/21/head
houssine 7 years ago
parent
commit
a251d1f0e3
  1. 21
      beesdoo_product/models/beesdoo_product.py
  2. 16
      beesdoo_product/views/beesdoo_product.xml

21
beesdoo_product/models/beesdoo_product.py

@ -36,6 +36,16 @@ class BeesdooProduct(models.Model):
ingredients = fields.Char(string="Ingredient") ingredients = fields.Char(string="Ingredient")
scale_label_info_1 = fields.Char(string="Scale lable info 1") scale_label_info_1 = fields.Char(string="Scale lable info 1")
scale_label_info_2 = fields.Char(string="Scale lable info 2") scale_label_info_2 = fields.Char(string="Scale lable info 2")
scale_sale_unit = fields.Char(compute="_get_scale_sale_uom", string="Scale sale unit", store=True)
@api.depends('uom_id','uom_id.category_id','uom_id.category_id.type')
@api.multi
def _get_scale_sale_uom(self):
for product in self:
if product.uom_id.category_id.type == 'unit':
product.scale_sale_unit = 'F'
elif product.uom_id.category_id.type == 'weight':
product.scale_sale_unit = 'P'
def _get_main_supplier_info(self): def _get_main_supplier_info(self):
return self.seller_ids.sorted(key=lambda seller: seller.date_start, reverse=True) return self.seller_ids.sorted(key=lambda seller: seller.date_start, reverse=True)
@ -125,3 +135,14 @@ class BeesdooProductSupplierInfo(models.Model):
price = fields.Float('exVAT Price') price = fields.Float('exVAT Price')
class BeesdooUOMCateg(models.Model):
_inherit = 'product.uom.categ'
type = fields.Selection([('unit','Unit'),
('weight','Weight'),
('time','Time'),
('distance','Distance'),
('surface','Surface'),
('volume','Volume'),
('other','Other')],string='Category type',default='unit')

16
beesdoo_product/views/beesdoo_product.xml

@ -53,6 +53,7 @@
</group> </group>
</page> </page>
<page string="Scale labels" attrs="{'invisible':[('to_weight','=',False)]}"> <page string="Scale labels" attrs="{'invisible':[('to_weight','=',False)]}">
<group>
<group name="scale_label"> <group name="scale_label">
<field name="deadline_for_sale"/> <field name="deadline_for_sale"/>
<field name="deadline_for_consumption"/> <field name="deadline_for_consumption"/>
@ -60,6 +61,10 @@
<field name="scale_label_info_1"/> <field name="scale_label_info_1"/>
<field name="scale_label_info_2"/> <field name="scale_label_info_2"/>
</group> </group>
<group>
<field name="scale_sale_unit"/>
</group>
</group>
</page> </page>
</xpath> </xpath>
</field> </field>
@ -134,4 +139,15 @@
<menuitem id="label_configuration_menu" name="Labels" parent="product.prod_config_main" <menuitem id="label_configuration_menu" name="Labels" parent="product.prod_config_main"
action="action_labels" sequence="20"/> action="action_labels" sequence="20"/>
<record id="beesdoo_product_uom_categ_form" model="ir.ui.view">
<field name="name">product.uom.categ.form</field>
<field name="model">product.uom.categ</field>
<field name="inherit_id" ref="product.product_uom_categ_form_view" />
<field name="arch" type="xml">
<field name="name" position="after">
<field name="type"/>
</field>
</field>
</record>
</odoo> </odoo>
Loading…
Cancel
Save