Browse Source

Merge pull request #21 from houssine78/9.0

add new fields and model for the scale integration
pull/22/head
Houssine BAKKALI 7 years ago
committed by GitHub
parent
commit
681c1f614e
  1. 33
      beesdoo_product/models/beesdoo_product.py
  2. 2
      beesdoo_product/security/ir.model.access.csv
  3. 51
      beesdoo_product/views/beesdoo_product.xml

33
beesdoo_product/models/beesdoo_product.py

@ -36,6 +36,18 @@ class BeesdooProduct(models.Model):
ingredients = fields.Char(string="Ingredient")
scale_label_info_1 = fields.Char(string="Scale lable info 1")
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)
scale_category = fields.Many2one('beesdoo.scale.category', string="Scale Category")
scale_category_code = fields.Integer(related='scale_category.code', string="Scale category code", readonly=True, 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):
return self.seller_ids.sorted(key=lambda seller: seller.date_start, reverse=True)
@ -101,6 +113,16 @@ class BeesdooProduct(models.Model):
if(len(suppliers) > 0):
self.suggested_price = (suppliers[0].price * self.uom_po_id.factor)* (1 + suppliers[0].product_tmpl_id.categ_id.profit_margin / 100)
class BeesdooScaleCategory(models.Model):
_name = "beesdoo.scale.category"
name = fields.Char(string="Scale name category")
code = fields.Integer(string="Category code")
_sql_constraints = [
('code_scale_categ_uniq', 'unique (code)', 'The code of the scale category must be unique !')
]
class BeesdooProductLabel(models.Model):
_name = "beesdoo.product.label"
@ -125,3 +147,14 @@ class BeesdooProductSupplierInfo(models.Model):
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')

2
beesdoo_product/security/ir.model.access.csv

@ -1,3 +1,5 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
beesdoo_product_label_read_all,beesdoo.product.label Read All,model_beesdoo_product_label,,1,0,0,0
beesdoo_product_label_all_access_sale_manager,beesdoo.product.label All Access Sale Manager,model_beesdoo_product_label,base.group_sale_manager,1,1,1,1
beesdoo_scale_category_read_all,beesdoo.scale.category Read All,model_beesdoo_scale_category,,1,0,0,0
beesdoo_scale_categoryl_all_access_sale_manager,beesdoo.scale.category All Access Sale Manager,model_beesdoo_scale_category,base.group_sale_manager,1,1,1,0

51
beesdoo_product/views/beesdoo_product.xml

@ -53,6 +53,7 @@
</group>
</page>
<page string="Scale labels" attrs="{'invisible':[('to_weight','=',False)]}">
<group>
<group name="scale_label">
<field name="deadline_for_sale"/>
<field name="deadline_for_consumption"/>
@ -60,6 +61,12 @@
<field name="scale_label_info_1"/>
<field name="scale_label_info_2"/>
</group>
<group>
<field name="scale_sale_unit"/>
<field name="scale_category" widget="selection"/>
<field name="scale_category_code"/>
</group>
</group>
</page>
</xpath>
</field>
@ -134,4 +141,48 @@
<menuitem id="label_configuration_menu" name="Labels" parent="product.prod_config_main"
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>
<record model="ir.ui.view" id="beesdoo_scale_category_list">
<field name="name">beesdoo.scale.category.list</field>
<field name="model">beesdoo.scale.category</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="code"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="beesdoo_scale_category_form">
<field name="name">beesdoo.scale.category.form</field>
<field name="model">beesdoo.scale.category</field>
<field name="arch" type="xml">
<form>
<group>
<field name="name"/>
<field name="code"/>
</group>
</form>
</field>
</record>
<record model="ir.actions.act_window" id="action_scale_categories">
<field name="name">Scale categories</field>
<field name="res_model">beesdoo.scale.category</field>
<field name="view_mode">tree,form</field>
</record>
<menuitem id="scale_categories_configuration_menu" name="Scale categories" parent="product.prod_config_main"
action="action_scale_categories" sequence="15"/>
</odoo>
Loading…
Cancel
Save