[IMP] sale,sale_stock: add incoterms
Display incoterms on sale orders and invoices
This commit is contained in:
committed by
Richard Mathot
parent
d45918bd74
commit
814dd5318c
@@ -44,7 +44,7 @@
|
||||
<strong>Customer Code:</strong>
|
||||
<p t-field="o.partner_id.ref"/>
|
||||
</div>
|
||||
<div class="col-xs-2" t-if="o.reference">
|
||||
<div name="reference" class="col-xs-2" t-if="o.reference">
|
||||
<strong>Reference:</strong>
|
||||
<p t-field="o.reference"/>
|
||||
</div>
|
||||
|
||||
@@ -51,6 +51,9 @@ Example: 10% for retailers, promotion of 5 EUR on this product, etc."""),
|
||||
'group_discount_per_so_line': fields.boolean("Allow setting a discount on the sales order lines",
|
||||
implied_group='sale.group_discount_per_so_line',
|
||||
help="Allows you to apply some discount per sales order line."),
|
||||
'group_display_incoterm':fields.boolean("Display incoterms on the printed sale orders and invoices reports",
|
||||
implied_group='sale.group_display_incoterm',
|
||||
help="The printed reports will display the incoterms for the sale orders and the related invoices"),
|
||||
'module_warning': fields.boolean("Allow configuring alerts by customer or products",
|
||||
help='Allow to configure notification on products and trigger them when a user wants to sell a given product or a given customer.\n'
|
||||
'Example: Product: this product is deprecated, do not purchase more than 5.\n'
|
||||
|
||||
@@ -44,6 +44,10 @@
|
||||
<field name="module_sale_stock" class="oe_inline"/>
|
||||
<label for="module_sale_stock"/>
|
||||
</div>
|
||||
<div name="display_incoterm" attrs="{'invisible': [('module_sale_stock', '!=', True)]}">
|
||||
<field name="group_display_incoterm" class="oe_inline"/>
|
||||
<label for="group_display_incoterm"/>
|
||||
</div>
|
||||
<div name='module_sale_journal'>
|
||||
<field name="module_sale_journal" class="oe_inline"/>
|
||||
<label for="module_sale_journal"/>
|
||||
|
||||
@@ -39,6 +39,11 @@
|
||||
<field name="category_id" ref="base.module_category_hidden"/>
|
||||
</record>
|
||||
|
||||
<record id="group_display_incoterm" model="res.groups">
|
||||
<field name="name">Display incoterms on Sales Order and related invoices</field>
|
||||
<field name="category_id" ref="base.module_category_hidden"/>
|
||||
</record>
|
||||
|
||||
<record id="group_analytic_accounting" model="res.groups">
|
||||
<field name="name">Analytic Accounting for Sales</field>
|
||||
<field name="category_id" ref="base.module_category_hidden"/>
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<strong>Salesperson:</strong>
|
||||
<p t-field="o.user_id.name"/>
|
||||
</div>
|
||||
<div t-if="o.payment_term" class="col-xs-3">
|
||||
<div name="payment_term" t-if="o.payment_term" class="col-xs-3">
|
||||
<strong>Payment Term:</strong>
|
||||
<p t-field="o.payment_term.name"/>
|
||||
</div>
|
||||
|
||||
@@ -55,6 +55,7 @@ You can choose flexible invoicing methods:
|
||||
'stock_view.xml',
|
||||
'res_config_view.xml',
|
||||
'report/sale_report_view.xml',
|
||||
'account_invoice_view.xml',
|
||||
],
|
||||
'demo': ['sale_stock_demo.xml'],
|
||||
'test': [
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
<record id="view_invoice_form_inherit" model="ir.ui.view">
|
||||
<field name="name">account.invoice.form.sale.stock</field>
|
||||
<field name="model">account.invoice</field>
|
||||
<field name="inherit_id" ref="account.invoice_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<data>
|
||||
<xpath expr="//field[@name='origin']" position="after">
|
||||
<field name="incoterms_id" widget="selection" groups="sale.group_display_incoterm"/>
|
||||
</xpath>
|
||||
</data>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<template id="report_invoice_incoterm" inherit_id="account.report_invoice_document">
|
||||
<xpath expr="//div[@name='reference']" position="after">
|
||||
<div class="col-xs-2" t-if="o.incoterms_id" groups="sale.group_display_incoterm">
|
||||
<strong>Incoterms:</strong>
|
||||
<p t-field="o.incoterms_id.code"/>
|
||||
</div>
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
@@ -80,8 +80,15 @@ class sale_order(osv.osv):
|
||||
vals['partner_dest_id'] = order.partner_shipping_id.id
|
||||
return vals
|
||||
|
||||
def _prepare_invoice(self, cr, uid, order, lines, context=None):
|
||||
if context is None:
|
||||
context = {}
|
||||
invoice_vals = super(sale_order, self)._prepare_invoice(cr, uid, order, lines, context=context)
|
||||
invoice_vals['incoterms_id'] = order.incoterm.id or False
|
||||
return invoice_vals
|
||||
|
||||
_columns = {
|
||||
'incoterm': fields.many2one('stock.incoterms', 'Incoterm', help="International Commercial Terms are a series of predefined commercial terms used in international transactions."),
|
||||
'incoterm': fields.many2one('stock.incoterms', 'Incoterms', help="International Commercial Terms are a series of predefined commercial terms used in international transactions."),
|
||||
'picking_policy': fields.selection([('direct', 'Deliver each product when available'), ('one', 'Deliver all products at once')],
|
||||
'Shipping Policy', required=True, readonly=True, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]},
|
||||
help="""Pick 'Deliver each product when available' if you allow partial delivery."""),
|
||||
@@ -442,3 +449,32 @@ class stock_picking(osv.osv):
|
||||
created_lines = sale_line_obj.invoice_line_create(cr, uid, sale_line_ids, context=context)
|
||||
invoice_line_obj.write(cr, uid, created_lines, {'invoice_id': invoice_id}, context=context)
|
||||
return invoice_id
|
||||
|
||||
|
||||
class account_invoice(osv.Model):
|
||||
_inherit = 'account.invoice'
|
||||
_columns = {
|
||||
'incoterms_id': fields.many2one(
|
||||
'stock.incoterms',
|
||||
"Incoterms",
|
||||
help="Incoterms are series of sales terms. They are used to divide transaction costs and responsibilities between buyer and seller and reflect state-of-the-art transportation practices.",
|
||||
readonly=True,
|
||||
states={'draft': [('readonly', False)]}),
|
||||
}
|
||||
|
||||
class sale_advance_payment_inv(osv.TransientModel):
|
||||
_inherit = 'sale.advance.payment.inv'
|
||||
|
||||
def _prepare_advance_invoice_vals(self, cr, uid, ids, context=None):
|
||||
result = super(sale_advance_payment_inv,self)._prepare_advance_invoice_vals(cr, uid, ids, context=context)
|
||||
if context is None:
|
||||
context = {}
|
||||
|
||||
sale_obj = self.pool.get('sale.order')
|
||||
sale_ids = context.get('active_ids', [])
|
||||
res = []
|
||||
for sale in sale_obj.browse(cr, uid, sale_ids, context=context):
|
||||
elem = filter(lambda t: t[0] == sale.id, result)[0]
|
||||
elem[1]['incoterms_id'] = sale.incoterm.id or False
|
||||
res.append(elem)
|
||||
return res
|
||||
|
||||
@@ -142,5 +142,15 @@
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<template id="report_sale_order_incoterm" inherit_id="sale.report_saleorder_document">
|
||||
<xpath expr="//div[@name='payment_term']" position="after">
|
||||
<div class="col-xs-3" t-if="o.incoterm" groups="sale.group_display_incoterm">
|
||||
<strong>Incoterms:</strong>
|
||||
<p t-field="o.incoterm.code"/>
|
||||
</div>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
Reference in New Issue
Block a user