Add Tax include / tax exclude next the prices on product form view
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
'views/account_move.xml',
|
'views/account_move.xml',
|
||||||
'views/account_menu.xml',
|
'views/account_menu.xml',
|
||||||
'views/account_tax.xml',
|
'views/account_tax.xml',
|
||||||
|
'views/product.xml',
|
||||||
'views/res_config_settings.xml',
|
'views/res_config_settings.xml',
|
||||||
'views/res_partner.xml',
|
'views/res_partner.xml',
|
||||||
'views/account_report.xml',
|
'views/account_report.xml',
|
||||||
|
|||||||
45
account_usability/models/product.py
Normal file
45
account_usability/models/product.py
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# Copyright 2015-2021 Akretion (http://www.akretion.com)
|
||||||
|
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
|
||||||
|
from odoo import api, fields, models, _
|
||||||
|
|
||||||
|
|
||||||
|
class ProductTemplate(models.Model):
|
||||||
|
_inherit = 'product.template'
|
||||||
|
|
||||||
|
# DON'T put store=True on those fields, because they are company dependent
|
||||||
|
sale_price_type = fields.Selection(
|
||||||
|
'_sale_purchase_price_type_sel', compute='_compute_sale_price_type',
|
||||||
|
string='Sale Price Type', compute_sudo=False, readonly=True)
|
||||||
|
purchase_price_type = fields.Selection(
|
||||||
|
'_sale_purchase_price_type_sel', compute='_compute_purchase_price_type',
|
||||||
|
string='Purchase Price Type', compute_sudo=False, readonly=True)
|
||||||
|
|
||||||
|
@api.model
|
||||||
|
def _sale_purchase_price_type_sel(self):
|
||||||
|
return [('incl', _('Tax incl.')), ('excl', _('Tax excl.'))]
|
||||||
|
|
||||||
|
@api.depends('taxes_id')
|
||||||
|
def _compute_sale_price_type(self):
|
||||||
|
for pt in self:
|
||||||
|
sale_price_type = 'incl'
|
||||||
|
if pt.taxes_id and all([not t.price_include for t in pt.taxes_id if t.amount_type == 'percent']):
|
||||||
|
sale_price_type = 'excl'
|
||||||
|
pt.sale_price_type = sale_price_type
|
||||||
|
|
||||||
|
@api.depends('supplier_taxes_id')
|
||||||
|
def _compute_purchase_price_type(self):
|
||||||
|
for pt in self:
|
||||||
|
purchase_price_type = 'incl'
|
||||||
|
if pt.supplier_taxes_id and all([not t.price_include for t in pt.supplier_taxes_id if t.amount_type == 'percent']):
|
||||||
|
purchase_price_type = 'excl'
|
||||||
|
pt.purchase_price_type = purchase_price_type
|
||||||
|
|
||||||
|
|
||||||
|
class ProductSupplierinfo(models.Model):
|
||||||
|
_inherit = 'product.supplierinfo'
|
||||||
|
|
||||||
|
# DON'T put store=True on those fields, because they are company dependent
|
||||||
|
purchase_price_type = fields.Selection(
|
||||||
|
related='product_tmpl_id.purchase_price_type', related_sudo=False)
|
||||||
73
account_usability/views/product.xml
Normal file
73
account_usability/views/product.xml
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright 2017-2020 Akretion (http://www.akretion.com/)
|
||||||
|
@author: Alexis de Lattre <alexis.delattre@akretion.com>
|
||||||
|
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||||
|
-->
|
||||||
|
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<!-- In the official account module, on product category and product template,
|
||||||
|
some fields/groups are on account.group_account_invoice, some on
|
||||||
|
account.group_account_user and some on account.group_account_manager
|
||||||
|
Here, we set all those fields on account.group_account_invoice
|
||||||
|
-->
|
||||||
|
|
||||||
|
<record id="product_template_form_view" model="ir.ui.view">
|
||||||
|
<field name="name">account_usability.product.template.form</field>
|
||||||
|
<field name="model">product.template</field>
|
||||||
|
<field name="priority">100</field> <!-- when you replace a field, it's always better to inherit at the end -->
|
||||||
|
<field name="inherit_id" ref="account.product_template_form_view"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="property_account_income_id" position="attributes">
|
||||||
|
<attribute name="groups">account.group_account_invoice</attribute>
|
||||||
|
</field>
|
||||||
|
<field name="property_account_expense_id" position="attributes">
|
||||||
|
<attribute name="groups">account.group_account_invoice</attribute>
|
||||||
|
</field>
|
||||||
|
<field name="list_price" position="replace">
|
||||||
|
<label for="list_price"/>
|
||||||
|
<div name="list_price">
|
||||||
|
<field name="list_price" widget='monetary' options="{'currency_field': 'currency_id'}" class="oe_inline"/>
|
||||||
|
<label for="sale_price_type" string=" "/>
|
||||||
|
<field name="sale_price_type"/>
|
||||||
|
</div>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="view_category_property_form" model="ir.ui.view">
|
||||||
|
<field name="name">account_usability.product.category.form</field>
|
||||||
|
<field name="model">product.category</field>
|
||||||
|
<field name="inherit_id" ref="account.view_category_property_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<group name="account_property" position="attributes">
|
||||||
|
<attribute name="groups">account.group_account_invoice</attribute>
|
||||||
|
</group>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="product_supplierinfo_form_view" model="ir.ui.view">
|
||||||
|
<field name="name">account_usability.product.supplierinfo.form</field>
|
||||||
|
<field name="model">product.supplierinfo</field>
|
||||||
|
<field name="inherit_id" ref="product.product_supplierinfo_form_view"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="currency_id" position="after">
|
||||||
|
<field name="purchase_price_type"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record id="product_supplierinfo_tree_view" model="ir.ui.view">
|
||||||
|
<field name="name">account_usability.product.supplierinfo.tree</field>
|
||||||
|
<field name="model">product.supplierinfo</field>
|
||||||
|
<field name="inherit_id" ref="product.product_supplierinfo_tree_view"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<field name="price" position="after">
|
||||||
|
<field name="purchase_price_type" string="Tax"/>
|
||||||
|
</field>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user