Add static legal terms on company for invoice and sale
Add product_supplier_code on purchase.order.line
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
'views/product.xml',
|
'views/product.xml',
|
||||||
'views/res_config_settings.xml',
|
'views/res_config_settings.xml',
|
||||||
'views/res_partner.xml',
|
'views/res_partner.xml',
|
||||||
|
'views/res_company.xml',
|
||||||
'views/account_report.xml',
|
'views/account_report.xml',
|
||||||
'wizard/account_invoice_mark_sent_view.xml',
|
'wizard/account_invoice_mark_sent_view.xml',
|
||||||
'wizard/account_group_generate_view.xml',
|
'wizard/account_group_generate_view.xml',
|
||||||
|
|||||||
@@ -6,4 +6,5 @@ from . import account_journal
|
|||||||
from . import account_move
|
from . import account_move
|
||||||
from . import account_partial_reconcile
|
from . import account_partial_reconcile
|
||||||
from . import res_partner
|
from . import res_partner
|
||||||
|
from . import res_company
|
||||||
from . import product
|
from . import product
|
||||||
|
|||||||
21
account_usability/models/res_company.py
Normal file
21
account_usability/models/res_company.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Copyright 2021 Akretion France (https://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 fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class ResCompany(models.Model):
|
||||||
|
_inherit = 'res.company'
|
||||||
|
|
||||||
|
# There is a native field invoice_terms which is displayed on res.config.settings
|
||||||
|
# when the ir.config_parameter account.use_invoice_terms is True
|
||||||
|
# But there are several problems with this native field:
|
||||||
|
# - it is copied on the 'narration' field of account.move => we don't want that
|
||||||
|
# - the text block is very small on the form view of res.config.settings
|
||||||
|
# So I decided to have our own field "fixed_invoice_terms"
|
||||||
|
# The native field can still be used when you need to customise some
|
||||||
|
# terms and conditions on each invoice (not very common, but...)
|
||||||
|
# To underline this different with the native field, I prefix it with 'static_'
|
||||||
|
static_invoice_terms = fields.Text(
|
||||||
|
translate=True, string="Legal Terms on Invoice")
|
||||||
27
account_usability/views/res_company.xml
Normal file
27
account_usability/views/res_company.xml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright 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).
|
||||||
|
-->
|
||||||
|
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
|
||||||
|
<record id="view_company_form" model="ir.ui.view">
|
||||||
|
<field name="name">account_usability.res.company.form</field>
|
||||||
|
<field name="model">res.company</field>
|
||||||
|
<field name="inherit_id" ref="base.view_company_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<notebook position="inside">
|
||||||
|
<page string="Legal Terms" name="legal_terms">
|
||||||
|
<group string="Invoice Legal Terms" name="static_invoice_terms">
|
||||||
|
<field name="static_invoice_terms" nolabel="1"/>
|
||||||
|
</group>
|
||||||
|
</page>
|
||||||
|
</notebook>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
</odoo>
|
||||||
@@ -73,3 +73,17 @@ class PurchaseOrderLine(models.Model):
|
|||||||
|
|
||||||
# for optional display in tree view
|
# for optional display in tree view
|
||||||
product_barcode = fields.Char(related='product_id.barcode', string="Product Barcode")
|
product_barcode = fields.Char(related='product_id.barcode', string="Product Barcode")
|
||||||
|
product_supplier_code = fields.Char(
|
||||||
|
compute='_compute_product_supplier_code', string='Vendor Product Code')
|
||||||
|
|
||||||
|
def _compute_product_supplier_code(self):
|
||||||
|
for line in self:
|
||||||
|
code = False
|
||||||
|
if not line.display_type and line.product_id and line.order_id:
|
||||||
|
partner_id = line.order_id.partner_id.commercial_partner_id.id
|
||||||
|
if partner_id:
|
||||||
|
for supplier_info in line.product_id.seller_ids:
|
||||||
|
if supplier_info.name.id == partner_id:
|
||||||
|
code = supplier_info.product_code
|
||||||
|
break
|
||||||
|
line.product_supplier_code = code
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
<attribute name="groups">analytic.group_analytic_tags</attribute>
|
<attribute name="groups">analytic.group_analytic_tags</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
<xpath expr="//field[@name='order_line']/tree//field[@name='product_id']" position="after">
|
<xpath expr="//field[@name='order_line']/tree//field[@name='product_id']" position="after">
|
||||||
|
<field name="product_supplier_code" optional="hide"/>
|
||||||
<field name="product_barcode" optional="hide"/>
|
<field name="product_barcode" optional="hide"/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
'website': 'http://www.akretion.com',
|
'website': 'http://www.akretion.com',
|
||||||
'depends': [
|
'depends': [
|
||||||
'sale',
|
'sale',
|
||||||
|
'account_usability', # for company view
|
||||||
'base_view_inheritance_extension',
|
'base_view_inheritance_extension',
|
||||||
],
|
],
|
||||||
'data': [
|
'data': [
|
||||||
@@ -20,6 +21,7 @@
|
|||||||
'views/sale_report.xml',
|
'views/sale_report.xml',
|
||||||
'views/product_pricelist_item.xml',
|
'views/product_pricelist_item.xml',
|
||||||
'views/account_move.xml',
|
'views/account_move.xml',
|
||||||
|
'views/res_company.xml',
|
||||||
],
|
],
|
||||||
'installable': True,
|
'installable': True,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ from . import sale_order
|
|||||||
from . import account_move
|
from . import account_move
|
||||||
from . import product_template
|
from . import product_template
|
||||||
from . import res_partner
|
from . import res_partner
|
||||||
|
from . import res_company
|
||||||
|
|||||||
13
sale_usability/models/res_company.py
Normal file
13
sale_usability/models/res_company.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Copyright 2021 Akretion France (https://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 fields, models
|
||||||
|
|
||||||
|
|
||||||
|
class ResCompany(models.Model):
|
||||||
|
_inherit = 'res.company'
|
||||||
|
|
||||||
|
# Similar to the field static_invoice_terms in account_usability
|
||||||
|
static_sale_terms = fields.Text(
|
||||||
|
translate=True, string="Legal Terms on Quotation")
|
||||||
25
sale_usability/views/res_company.xml
Normal file
25
sale_usability/views/res_company.xml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright 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).
|
||||||
|
-->
|
||||||
|
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
|
||||||
|
<record id="view_company_form" model="ir.ui.view">
|
||||||
|
<field name="name">sale_usability.res.company.form</field>
|
||||||
|
<field name="model">res.company</field>
|
||||||
|
<field name="inherit_id" ref="account_usability.view_company_form"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<group name="static_invoice_terms" position="after">
|
||||||
|
<group name="static_sale_terms" string="Quotation Legal Terms">
|
||||||
|
<field name="static_sale_terms" nolabel="1"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
</odoo>
|
||||||
Reference in New Issue
Block a user