Browse Source

Add total and total_with_vat fields

pull/9/head
gregoire 9 years ago
parent
commit
eadee14bd2
  1. 54
      beesdoo_product/models/beesdoo_product.py
  2. 98
      beesdoo_product/views/beesdoo_product.xml

54
beesdoo_product/models/beesdoo_product.py

@ -1,18 +1,54 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
from openerp import models, fields, api from openerp import models, fields, api
class BeesdooProduct(models.Model): class BeesdooProduct(models.Model):
_inherit = "product.template"
_inherit = 'product.template'
eco_label = fields.Many2one('beesdoo.product.label', domain=[('type', '=', 'eco')])
local_label = fields.Many2one('beesdoo.product.label', domain=[('type', '=', 'local')])
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')
total = fields.Float(compute='get_total')
total_with_vat = fields.Float(compute='get_total_with_vat')
def get_display_weight(self):
pass
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:
tax_amount_sum = tax_amount_sum + tax.amount
self.total_with_vat = self.total * (100.0 + tax_amount_sum) / 100
eco_label = fields.Many2one('beesdoo.product.label', domain = [('type', '=', 'eco')])
local_label = fields.Many2one('beesdoo.product.label', domain = [('type', '=', 'local')])
fair_label = fields.Many2one('beesdoo.product.label', domain = [('type', '=', 'fair')])
origin_label = fields.Many2one('beesdoo.product.label', domain = [('type', '=', 'delivery')])
class BeesdooProductLabel(models.Model): class BeesdooProductLabel(models.Model):
_name = "beesdoo.product.label"
_name = 'beesdoo.product.label'
name = fields.Char() name = fields.Char()
type = fields.Selection([('eco', 'Écologique'), ('local', 'Local'), ('fair', 'Équitable'), ('delivery', 'Distribution')])
type = fields.Selection(
[('eco', 'Écologique'), ('local', 'Local'), ('fair', 'Équitable'), ('delivery', 'Distribution')])
color_code = fields.Char() color_code = fields.Char()

98
beesdoo_product/views/beesdoo_product.xml

@ -1,30 +1,86 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<odoo> <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>
<!--<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"> <field name="arch" type="xml">
<form>
<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="eco_label"/>
<field name="local_label"/>
<field name="fair_label"/>
<field name="origin_label"/>
</group>
<group> <group>
<field name="name" />
<field name="type" />
<field name="color_code" />
<field name="display_weight"/>
</group> </group>
</form>
</page>
</xpath>
</field> </field>
</record> </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> </odoo>
Loading…
Cancel
Save