Browse Source

add total by unit and clean xml

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

14
beesdoo_product/models/beesdoo_product.py

@ -18,22 +18,32 @@ class BeesdooProduct(models.Model):
total = fields.Float(compute='get_total')
total_with_vat = fields.Float(compute='get_total_with_vat')
total_with_vat_by_unit = fields.Float(compute='get_total_with_vat_by_unit')
@api.one
@api.depends('weight', 'display_unit')
def get_display_weight(self):
if self.display_unit:
self.display_weight = self.weight / self.display_unit.factor
@api.one
def get_total(self):
price_ht = self.env['product.pricelist'].search([])[0].price_get(self.id, 1)[1]
self.total = price_ht
@api.one
def get_total_with_vat(self):
tax_amount_sum = 0.0
for tax in self.taxes_id:
tax_amount_sum = tax_amount_sum + tax.amount
if hasattr(self, 'taxes_id'):
for tax in self.taxes_id:
tax_amount_sum = tax_amount_sum + tax.amount
self.total_with_vat = self.total * (100.0 + tax_amount_sum) / 100
@api.one
def get_total_with_vat_by_unit(self):
if self.display_weight > 0:
self.total_with_vat_by_unit = self.total_with_vat/self.display_weight
class BeesdooProductLabel(models.Model):
_name = 'beesdoo.product.label'

78
beesdoo_product/views/beesdoo_product.xml

@ -1,63 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!--<record model="ir.ui.view" id="beesdoo_product_form">-->
<!--<field name="name">bees.product.template.form</field>-->
<!--<field name="model">product.template</field>-->
<!--<field name="inherit_id" ref="product.product_template_only_form_view"/>-->
<!--<field name="arch" type="xml">-->
<!--<field name="barcode" position="after">-->
<!--<field name="eco_label"/>-->
<!--<field name="local_label"/>-->
<!--<field name="fair_label"/>-->
<!--<field name="origin_label"/>-->
<!--</field>-->
<!--</field>-->
<!--</record>-->
<!--<record model="ir.ui.view" id="beesdoo_product_label_form">-->
<!--<field name="name">bees.product.label.form</field>-->
<!--<field name="model">beesdoo.product.label</field>-->
<!--<field name="arch" type="xml">-->
<!--<form>-->
<!--<group>-->
<!--<field name="name"/>-->
<!--<field name="type"/>-->
<!--<field name="color_code"/>-->
<!--</group>-->
<!--</form>-->
<!--</field>-->
<!--</record>-->
<!--<record model="ir.ui.view" id="beesdoo_product_label_form">-->
<!--<field name="name">bees.product.label.form</field>-->
<!--<field name="model">beesdoo.product.label</field>-->
<!--<field name="arch" type="xml">-->
<!--<form>-->
<!--<group>-->
<!--<field name="name"/>-->
<!--<field name="type"/>-->
<!--<field name="color_code"/>-->
<!--</group>-->
<!--</form>-->
<!--</field>-->
<!--</record>-->
<record model="ir.ui.view" id="product_template_form_view">
<field name="name">bees.product</field>
<field name="model">product.template</field>
<field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml">
<xpath expr="//group[@name='inventory']/.." position="after">
<page string="Étiquette">
<page string="Price tag">
<group name="label">
<field name="total"/>
<field name="total_with_vat"/>
<field name="default_reference_unit"/>
<field name="display_weight"/>
<field name="total_with_vat_by_unit"/>
</group>
<group>
<field name="display_weight"/>
<field name="eco_label"/>
<field name="local_label"/>
<field name="fair_label"/>
@ -68,32 +24,4 @@
</field>
</record>
<record model="ir.ui.view" id="product_template_form_view">
<field name="name">bees.product</field>
<field name="model">product.supplierinfo</field>
<field name="inherit_id" ref="product_template_form_view"/>
<field name="arch" type="xml">
<group name="label" position="after">
<group>
<field name="name"/>
</group>
</group>
</field>
</record>
<!--<record model="ir.ui.view" id="beesdoo_product_label_form">-->
<!--<field name="name">bees.product.label.form</field>-->
<!--<field name="model">beesdoo.product.label</field>-->
<!--<field name="arch" type="xml">-->
<!--<form>-->
<!--<group>-->
<!--<field name="name"/>-->
<!--<field name="type"/>-->
<!--<field name="color_code"/>-->
<!--</group>-->
<!--</form>-->
<!--</field>-->
<!--</record>-->
</odoo>
Loading…
Cancel
Save