Browse Source

[ADD] custom beesdoo product view

pull/46/head
robinkeunen 6 years ago
parent
commit
b91212a79a
  1. 8
      beesdoo_product/__openerp__.py
  2. 23
      beesdoo_product/models/beesdoo_product.py
  3. 24
      beesdoo_product/views/beesdoo_product.xml

8
beesdoo_product/__openerp__.py

@ -20,7 +20,13 @@
'version': '0.1', 'version': '0.1',
# any module necessary for this one to work correctly # any module necessary for this one to work correctly
'depends': ['beesdoo_base', 'product', 'point_of_sale','pos_price_to_weight'],
'depends': [
'beesdoo_base',
'product',
'point_of_sale',
'pos_price_to_weight',
'stock_coverage',
],
# always loaded # always loaded
'data': [ 'data': [

23
beesdoo_product/models/beesdoo_product.py

@ -15,6 +15,20 @@ class BeesdooProduct(models.Model):
main_seller_id = fields.Many2one('res.partner', compute='_compute_main_seller_id', store=True) main_seller_id = fields.Many2one('res.partner', compute='_compute_main_seller_id', store=True)
main_supplierinfo = fields.Many2one(
'product.supplierinfo',
string='Main Supplier Information',
compute='_compute_main_supplierinfo'
)
main_price = fields.Float(
string='Price',
compute='_compute_main_supplierinfo',
)
main_minimum_qty = fields.Float(
string='Minimum Quantity',
compute='_compute_main_supplierinfo',
)
display_unit = fields.Many2one('product.uom') display_unit = fields.Many2one('product.uom')
default_reference_unit = fields.Many2one('product.uom') default_reference_unit = fields.Many2one('product.uom')
display_weight = fields.Float(compute='_get_display_weight', store=True) display_weight = fields.Float(compute='_get_display_weight', store=True)
@ -50,6 +64,15 @@ class BeesdooProduct(models.Model):
elif product.uom_id.category_id.type == 'weight': elif product.uom_id.category_id.type == 'weight':
product.scale_sale_unit = 'P' product.scale_sale_unit = 'P'
@api.multi
@api.depends('seller_ids')
def _compute_main_supplierinfo(self):
for product in self:
supplierinfo = product._get_main_supplier_info()
product.main_supplierinfo = supplierinfo
product.main_price = supplierinfo.price
product.main_minimum_qty = supplierinfo.min_qty
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)

24
beesdoo_product/views/beesdoo_product.xml

@ -72,6 +72,30 @@
</field> </field>
</record> </record>
<record model="ir.ui.view" id="beesdoo_product_tree">
<field name="name">bees.product.template.tree</field>
<field name="model">product.template</field>
<field name="priority">14</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="categ_id"/>
<field name="main_seller_id"/>
<field name="weight"/>
<field name="main_price"/>
<field name="main_minimum_qty"/>
<field name="uom_id"/>
<field name="qty_available"/>
<field name="virtual_available"/>
<field name="estimated_stock_coverage"/>
<field name="average_consumption"/>
<field name="total_consumption"/>
</tree>
</field>
</record>
<record model="ir.ui.view" id="beesdoo_product_label_form"> <record model="ir.ui.view" id="beesdoo_product_label_form">
<field name="name">bees.product.label.form</field> <field name="name">bees.product.label.form</field>
<field name="model">beesdoo.product.label</field> <field name="model">beesdoo.product.label</field>

Loading…
Cancel
Save