diff --git a/addons/account/account_invoice.py b/addons/account/account_invoice.py index eb362455cd9..2d09753e584 100644 --- a/addons/account/account_invoice.py +++ b/addons/account/account_invoice.py @@ -1260,9 +1260,7 @@ class account_invoice(osv.osv): ref = invoice.reference else: ref = self._convert_ref(cr, uid, invoice.number) - partner = invoice.partner_id - if partner.parent_id and not partner.is_company: - partner = partner.parent_id + partner = self.pool['res.partner']._find_accounting_partner(invoice.partner_id) # Pay attention to the sign for both debit/credit AND amount_currency l1 = { 'debit': direction * pay_amount>0 and direction * pay_amount, @@ -1733,15 +1731,17 @@ class res_partner(osv.osv): 'invoice_ids': fields.one2many('account.invoice.line', 'partner_id', 'Invoices', readonly=True), } - def _find_accounting_partner(self, part): + def _find_accounting_partner(self, partner): ''' Find the partner for which the accounting entries will be created ''' + # FIXME: after 7.0, to replace by function field partner.commercial_partner_id + #if the chosen partner is not a company and has a parent company, use the parent for the journal entries #because you want to invoice 'Agrolait, accounting department' but the journal items are for 'Agrolait' - if part.parent_id and not part.is_company: - part = part.parent_id - return part + while not partner.is_company and partner.parent_id: + partner = partner.parent_id + return partner def copy(self, cr, uid, id, default=None, context=None): default = default or {} diff --git a/addons/account/account_invoice_view.xml b/addons/account/account_invoice_view.xml index 8c7cec67ac5..046350f302e 100644 --- a/addons/account/account_invoice_view.xml +++ b/addons/account/account_invoice_view.xml @@ -320,7 +320,8 @@ + options='{"always_reload": True}' + domain="[('customer', '=', True)]"/> @@ -447,14 +448,14 @@ account.invoice - + - + diff --git a/addons/account/partner.py b/addons/account/partner.py index ae8d2fc1871..4914a17dd2b 100644 --- a/addons/account/partner.py +++ b/addons/account/partner.py @@ -236,6 +236,11 @@ class res_partner(osv.osv): 'last_reconciliation_date': fields.datetime('Latest Full Reconciliation Date', help='Date on which the partner accounting entries were fully reconciled last time. It differs from the last date where a reconciliation has been made for this partner, as here we depict the fact that nothing more was to be reconciled at this date. This can be achieved in 2 different ways: either the last unreconciled debit/credit entry of this partner was reconciled, either the user pressed the button "Nothing more to reconcile" during the manual reconciliation process.') } + def _commercial_fields(self, cr, uid, context=None): + return super(res_partner, self)._commercial_fields(cr, uid, context=context) + \ + ['debit_limit', 'property_account_payable', 'property_account_receivable', 'property_account_position', + 'property_payment_term', 'property_supplier_payment_term', 'last_reconciliation_date'] + res_partner() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/partner_view.xml b/addons/account/partner_view.xml index 1267e20165b..abded67f6ab 100644 --- a/addons/account/partner_view.xml +++ b/addons/account/partner_view.xml @@ -73,7 +73,7 @@ - + @@ -103,6 +103,11 @@ + +
+

Accounting-related settings are managed on

+
diff --git a/addons/account/project/project_view.xml b/addons/account/project/project_view.xml index aa567d2fc79..79a1e76c7e7 100644 --- a/addons/account/project/project_view.xml +++ b/addons/account/project/project_view.xml @@ -31,7 +31,7 @@ - + diff --git a/addons/account_analytic_analysis/account_analytic_analysis_view.xml b/addons/account_analytic_analysis/account_analytic_analysis_view.xml index a9437267611..8d7a89e4622 100644 --- a/addons/account_analytic_analysis/account_analytic_analysis_view.xml +++ b/addons/account_analytic_analysis/account_analytic_analysis_view.xml @@ -186,7 +186,7 @@ - + diff --git a/addons/account_asset/account_asset_view.xml b/addons/account_asset/account_asset_view.xml index c4cb17bded3..fe1fcf473ba 100644 --- a/addons/account_asset/account_asset_view.xml +++ b/addons/account_asset/account_asset_view.xml @@ -223,7 +223,7 @@ - + diff --git a/addons/account_asset/report/account_asset_report_view.xml b/addons/account_asset/report/account_asset_report_view.xml index 4865196c4a8..c772c6e4103 100644 --- a/addons/account_asset/report/account_asset_report_view.xml +++ b/addons/account_asset/report/account_asset_report_view.xml @@ -49,7 +49,7 @@ - + diff --git a/addons/account_report_company/__init__.py b/addons/account_report_company/__init__.py new file mode 100644 index 00000000000..42ec779494e --- /dev/null +++ b/addons/account_report_company/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (c) 2013 OpenERP S.A. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import account_report_company +import report + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_report_company/__openerp__.py b/addons/account_report_company/__openerp__.py new file mode 100644 index 00000000000..6c2f89c62c0 --- /dev/null +++ b/addons/account_report_company/__openerp__.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (c) 2013 OpenERP S.A. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +{ + 'name': 'Invoice Analysis per Company', + 'version': '1.0', + 'category': 'Accounting & Finance', + 'description': """ +Add an extra Company dimension on Invoices for consolidated Invoice Analysis +============================================================================ + +By default Customer and Supplier invoices can be linked to a contact within +a company, but the company is not a direct reference in the database structure for +invoices. Journal Entries are however always linked to the company and not to +contacts, so that Accounts Payable and Receivable are always correct and consolidated +at company level. + +When many different contacts/departments need to be invoiced within the same parent company, +this can make reporting by Company more difficult: reports are directly based on the +database structure and would not provide an aggregated company dimension. + +This modules solves the problem by adding an explicit company reference on invoices, +automatically computed from the invoice contact, and use this new dimension +when grouping the list of Invoices or the Invoice Analysis report by Partner. + +Note: this module will likely be removed for the next major OpenERP version and +directly integrated in the core accounting. +""", + 'author': 'OpenERP SA', + 'website': 'http://www.openerp.com', + 'depends': ['account'], + 'data': [ + 'account_invoice_view.xml', + 'res_partner_view.xml', + 'report/account_invoice_report_view.xml', + ], + 'auto_install': True, +} + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_report_company/account_invoice_view.xml b/addons/account_report_company/account_invoice_view.xml new file mode 100644 index 00000000000..89479c5a5e7 --- /dev/null +++ b/addons/account_report_company/account_invoice_view.xml @@ -0,0 +1,24 @@ + + + + + account.invoice + + + + + + + + + + account.invoice + + + + + + + + + \ No newline at end of file diff --git a/addons/account_report_company/account_report_company.py b/addons/account_report_company/account_report_company.py new file mode 100644 index 00000000000..0c102fcc4e1 --- /dev/null +++ b/addons/account_report_company/account_report_company.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (c) 2013 S.A. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from openerp.osv import osv, fields + +class res_partner(osv.Model): + _inherit = 'res.partner' + _order = 'display_name' + + def _display_name_compute(self, cr, uid, ids, name, args, context=None): + return dict(self.name_get(cr, uid, ids, context=context)) + + _display_name_store_triggers = { + 'res.partner': (lambda self,cr,uid,ids,context=None: self.search(cr, uid, [('id','child_of',ids)]), + ['parent_id', 'is_company'], 10) + } + + # indirection to avoid passing a copy of the overridable method when declaring the function field + _display_name = lambda self, *args, **kwargs: self._display_name_compute(*args, **kwargs) + + _columns = { + # extra field to allow ORDER BY to match visible names + 'display_name': fields.function(_display_name, type='char', string='Name', store=_display_name_store_triggers), + } + +class account_invoice(osv.Model): + _inherit = 'account.invoice' + + _columns = { + 'commercial_partner_id': fields.related('partner_id', 'commercial_partner_id', string='Commercial Entity', type='many2one', + relation='res.partner', store=True, readonly=True, + help="The commercial entity that will be used on Journal Entries for this invoice") + } diff --git a/addons/account_report_company/report/__init__.py b/addons/account_report_company/report/__init__.py new file mode 100644 index 00000000000..0fa7453c913 --- /dev/null +++ b/addons/account_report_company/report/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (c) 2013 OpenERP S.A. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +import account_invoice_report + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_report_company/report/account_invoice_report.py b/addons/account_report_company/report/account_invoice_report.py new file mode 100644 index 00000000000..5941aef9e6e --- /dev/null +++ b/addons/account_report_company/report/account_invoice_report.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (c) 2013 OpenERP S.A. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## +from openerp.osv import osv, fields + +class account_invoice_report(osv.Model): + _inherit = 'account.invoice.report' + _columns = { + 'commercial_partner_id': fields.many2one('res.partner', 'Partner Company', help="Commercial Entity"), + } + + def _select(self): + return super(account_invoice_report, self)._select() + ", sub.commercial_partner_id as commercial_partner_id" + + def _sub_select(self): + return super(account_invoice_report, self)._sub_select() + ", ai.commercial_partner_id as commercial_partner_id" + + def _group_by(self): + return super(account_invoice_report, self)._group_by() + ", ai.commercial_partner_id" diff --git a/addons/account_report_company/report/account_invoice_report_view.xml b/addons/account_report_company/report/account_invoice_report_view.xml new file mode 100644 index 00000000000..90fa4bdf2ec --- /dev/null +++ b/addons/account_report_company/report/account_invoice_report_view.xml @@ -0,0 +1,24 @@ + + + + + account.invoice.report + + + + + + + + + + account.invoice.report + + + + + + + + + \ No newline at end of file diff --git a/addons/account_report_company/res_partner_view.xml b/addons/account_report_company/res_partner_view.xml new file mode 100644 index 00000000000..cae010f3066 --- /dev/null +++ b/addons/account_report_company/res_partner_view.xml @@ -0,0 +1,24 @@ + + + + + res.partner + + + + + + + + + + res.partner + + + + + + + + + \ No newline at end of file diff --git a/addons/account_voucher/account_voucher_view.xml b/addons/account_voucher/account_voucher_view.xml index f429480f656..4674d62b6a0 100644 --- a/addons/account_voucher/account_voucher_view.xml +++ b/addons/account_voucher/account_voucher_view.xml @@ -129,7 +129,7 @@ - + diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index de873c9195c..109c2f9aec9 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -11,7 +11,7 @@ - + @@ -34,7 +34,7 @@ - + diff --git a/addons/account_voucher/voucher_sales_purchase_view.xml b/addons/account_voucher/voucher_sales_purchase_view.xml index 05b783dd339..6a84a09d5e6 100644 --- a/addons/account_voucher/voucher_sales_purchase_view.xml +++ b/addons/account_voucher/voucher_sales_purchase_view.xml @@ -10,7 +10,7 @@ - + @@ -32,7 +32,7 @@ - + diff --git a/addons/base_vat/base_vat.py b/addons/base_vat/base_vat.py index 616333e3b47..3366101c7c7 100644 --- a/addons/base_vat/base_vat.py +++ b/addons/base_vat/base_vat.py @@ -134,6 +134,9 @@ class res_partner(osv.osv): 'vat_subjected': fields.boolean('VAT Legal Statement', help="Check this box if the partner is subjected to the VAT. It will be used for the VAT legal statement.") } + def _commercial_fields(self, cr, uid, context=None): + return super(res_partner, self)._commercial_fields(cr, uid, context=context) + ['vat_subjected'] + def _construct_constraint_msg(self, cr, uid, ids, context=None): def default_vat_check(cn, vn): # by default, a VAT number is valid if: diff --git a/addons/crm/crm_lead_view.xml b/addons/crm/crm_lead_view.xml index fb18e747fd7..be153167473 100644 --- a/addons/crm/crm_lead_view.xml +++ b/addons/crm/crm_lead_view.xml @@ -328,7 +328,7 @@ - + @@ -546,7 +546,7 @@ - + diff --git a/addons/crm/crm_phonecall_view.xml b/addons/crm/crm_phonecall_view.xml index 67df85e6178..4530f412e07 100644 --- a/addons/crm/crm_phonecall_view.xml +++ b/addons/crm/crm_phonecall_view.xml @@ -185,7 +185,7 @@ - + diff --git a/addons/crm/report/crm_lead_report_view.xml b/addons/crm/report/crm_lead_report_view.xml index 0e5df8837f1..f05e8ee896b 100644 --- a/addons/crm/report/crm_lead_report_view.xml +++ b/addons/crm/report/crm_lead_report_view.xml @@ -80,7 +80,7 @@ - + diff --git a/addons/crm/report/crm_phonecall_report_view.xml b/addons/crm/report/crm_phonecall_report_view.xml index 1f1a4f91046..06966f3a0a8 100644 --- a/addons/crm/report/crm_phonecall_report_view.xml +++ b/addons/crm/report/crm_phonecall_report_view.xml @@ -62,7 +62,7 @@ - + diff --git a/addons/crm_claim/crm_claim_view.xml b/addons/crm_claim/crm_claim_view.xml index b1ab72e20f6..f545406187d 100644 --- a/addons/crm_claim/crm_claim_view.xml +++ b/addons/crm_claim/crm_claim_view.xml @@ -201,7 +201,7 @@ - + diff --git a/addons/crm_claim/report/crm_claim_report_view.xml b/addons/crm_claim/report/crm_claim_report_view.xml index a61490c6086..a9a4bcb27c1 100644 --- a/addons/crm_claim/report/crm_claim_report_view.xml +++ b/addons/crm_claim/report/crm_claim_report_view.xml @@ -63,7 +63,7 @@ - + diff --git a/addons/crm_helpdesk/crm_helpdesk_view.xml b/addons/crm_helpdesk/crm_helpdesk_view.xml index 6c0e3433afe..d833e7bbcf6 100644 --- a/addons/crm_helpdesk/crm_helpdesk_view.xml +++ b/addons/crm_helpdesk/crm_helpdesk_view.xml @@ -152,7 +152,7 @@ - + diff --git a/addons/crm_helpdesk/report/crm_helpdesk_report_view.xml b/addons/crm_helpdesk/report/crm_helpdesk_report_view.xml index 05f502656d2..f6522a15c9f 100644 --- a/addons/crm_helpdesk/report/crm_helpdesk_report_view.xml +++ b/addons/crm_helpdesk/report/crm_helpdesk_report_view.xml @@ -62,6 +62,7 @@ + diff --git a/addons/l10n_be_invoice_bba/partner.py b/addons/l10n_be_invoice_bba/partner.py index 9e0eec10713..df68268bf43 100644 --- a/addons/l10n_be_invoice_bba/partner.py +++ b/addons/l10n_be_invoice_bba/partner.py @@ -44,6 +44,11 @@ class res_partner(osv.osv): help='Select Algorithm to generate the Structured Communication on Outgoing Invoices.' ), } + def _commercial_fields(self, cr, uid, context=None): + return super(res_partner, self)._commercial_fields(cr, uid, context=context) + \ + ['out_inv_comm_type', 'out_inv_comm_algorithm'] + + _default = { 'out_inv_comm_type': 'none', } diff --git a/addons/l10n_ro/res_partner.py b/addons/l10n_ro/res_partner.py index 1cfe7390a77..4720c6f8157 100755 --- a/addons/l10n_ro/res_partner.py +++ b/addons/l10n_ro/res_partner.py @@ -28,10 +28,33 @@ class res_partner(osv.osv): _columns = { 'nrc' : fields.char('NRC', size=16, help='Registration number at the Registry of Commerce'), } + + # The SQL constraints are no-ops but present only to display the right error message to the + # user when the partial unique indexes defined below raise errors/ + # The real constraints need to be implemented with PARTIAL UNIQUE INDEXES (see auto_init), + # due to the way accounting data is delegated by contacts to their companies in OpenERP 7.0. _sql_constraints = [ - ('vat_uniq', 'unique (vat)', 'The vat of the partner must be unique !'), - ('nrc_uniq', 'unique (nrc)', 'The code of the partner must be unique !') + ('vat_uniq', 'unique (id)', 'The vat of the partner must be unique !'), + ('nrc_uniq', 'unique (id)', 'The code of the partner must be unique !') ] + + def _auto_init(self, cr, context=None): + result = super(res_partner, self)._auto_init(cr, context=context) + # Real implementation of the vat/nrc constraints: only "commercial entities" need to have + # unique numbers, and the condition for being a commercial entity is "is_company or parent_id IS NULL". + # Contacts inside a company automatically have a copy of the company's commercial fields + # (see _commercial_fields()), so they are automatically consistent. + cr.execute(""" + DROP INDEX IF EXISTS res_partner_vat_uniq_for_companies; + DROP INDEX IF EXISTS res_partner_nrc_uniq_for_companies; + CREATE UNIQUE INDEX res_partner_vat_uniq_for_companies ON res_partner (vat) WHERE is_company OR parent_id IS NULL; + CREATE UNIQUE INDEX res_partner_nrc_uniq_for_companies ON res_partner (nrc) WHERE is_company OR parent_id IS NULL; + """) + return result + + def _commercial_fields(self, cr, uid, context=None): + return super(res_partner, self)._commercial_fields(cr, uid, context=context) + ['nrc'] + res_partner() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/mrp_repair/mrp_repair_view.xml b/addons/mrp_repair/mrp_repair_view.xml index d35a9ebcf1d..a4526b5b581 100644 --- a/addons/mrp_repair/mrp_repair_view.xml +++ b/addons/mrp_repair/mrp_repair_view.xml @@ -210,7 +210,7 @@ - + diff --git a/addons/product/partner.py b/addons/product/partner.py index 1d11e909346..4a291a8ddd3 100644 --- a/addons/product/partner.py +++ b/addons/product/partner.py @@ -36,6 +36,9 @@ class res_partner(osv.osv): help="This pricelist will be used, instead of the default one, for sales to the current partner"), } + def _commercial_fields(self, cr, uid, context=None): + return super(res_partner, self)._commercial_fields(cr, uid, context=context) + ['property_product_pricelist'] + res_partner() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/product/partner_view.xml b/addons/product/partner_view.xml index acb087533ac..5117da6044e 100644 --- a/addons/product/partner_view.xml +++ b/addons/product/partner_view.xml @@ -8,9 +8,12 @@ - + +
+

Pricelists are managed on

diff --git a/addons/project/project_view.xml b/addons/project/project_view.xml index e25a5b1eb93..f0092a1dd33 100644 --- a/addons/project/project_view.xml +++ b/addons/project/project_view.xml @@ -182,7 +182,7 @@ - + diff --git a/addons/project/report/project_report_view.xml b/addons/project/report/project_report_view.xml index 10f3f4a8c7c..d9650e165ce 100644 --- a/addons/project/report/project_report_view.xml +++ b/addons/project/report/project_report_view.xml @@ -69,7 +69,7 @@ - + diff --git a/addons/project_issue/project_issue_view.xml b/addons/project_issue/project_issue_view.xml index f4710766d61..74c83afd304 100644 --- a/addons/project_issue/project_issue_view.xml +++ b/addons/project_issue/project_issue_view.xml @@ -139,7 +139,7 @@ project.issue - + @@ -150,6 +150,7 @@ + diff --git a/addons/project_issue/report/project_issue_report_view.xml b/addons/project_issue/report/project_issue_report_view.xml index 47ea91fad5f..93233704e65 100644 --- a/addons/project_issue/report/project_issue_report_view.xml +++ b/addons/project_issue/report/project_issue_report_view.xml @@ -55,7 +55,7 @@ - + diff --git a/addons/purchase/partner.py b/addons/purchase/partner.py index 56eaf288fe6..e05f6b9c9c6 100644 --- a/addons/purchase/partner.py +++ b/addons/purchase/partner.py @@ -43,6 +43,9 @@ class res_partner(osv.osv): super(res_partner, self).copy(cr, uid, id, default=default, context=context) + def _commercial_fields(self, cr, uid, context=None): + return super(res_partner, self)._commercial_fields(cr, uid, context=context) + ['property_product_pricelist_purchase'] + _columns = { 'property_product_pricelist_purchase': fields.property( 'product.pricelist', diff --git a/addons/purchase/purchase_view.xml b/addons/purchase/purchase_view.xml index 067dcd3e45b..23c153b0ae8 100644 --- a/addons/purchase/purchase_view.xml +++ b/addons/purchase/purchase_view.xml @@ -270,7 +270,7 @@ - + @@ -297,7 +297,7 @@ - + @@ -481,7 +481,7 @@ - + diff --git a/addons/sale/res_partner_view.xml b/addons/sale/res_partner_view.xml index 54a9813eea9..40ac119fdee 100644 --- a/addons/sale/res_partner_view.xml +++ b/addons/sale/res_partner_view.xml @@ -63,14 +63,34 @@ sale.group_delivery_invoice_address - - False False + sale.group_delivery_invoice_address - + + False + sale.group_delivery_invoice_address + + + False + sale.group_delivery_invoice_address + + + False + sale.group_delivery_invoice_address + + + False + sale.group_delivery_invoice_address + + + False + sale.group_delivery_invoice_address + + + False sale.group_delivery_invoice_address diff --git a/addons/sale/sale.py b/addons/sale/sale.py index 1d52adb358d..2518a801eb2 100644 --- a/addons/sale/sale.py +++ b/addons/sale/sale.py @@ -314,10 +314,6 @@ class sale_order(osv.osv): return {'value': {'partner_invoice_id': False, 'partner_shipping_id': False, 'payment_term': False, 'fiscal_position': False}} part = self.pool.get('res.partner').browse(cr, uid, part, context=context) - #if the chosen partner is not a company and has a parent company, use the parent to choose the delivery, the - #invoicing addresses and all the fields related to the partner. - if part.parent_id and not part.is_company: - part = part.parent_id addr = self.pool.get('res.partner').address_get(cr, uid, [part.id], ['delivery', 'invoice', 'contact']) pricelist = part.property_product_pricelist and part.property_product_pricelist.id or False payment_term = part.property_payment_term and part.property_payment_term.id or False diff --git a/addons/sale/sale_view.xml b/addons/sale/sale_view.xml index 9dc5f51d8aa..e365ecf6c73 100644 --- a/addons/sale/sale_view.xml +++ b/addons/sale/sale_view.xml @@ -156,7 +156,7 @@ - + @@ -308,7 +308,7 @@ - + @@ -472,7 +472,7 @@ - + @@ -498,7 +498,7 @@ - + diff --git a/addons/sale_journal/sale_journal.py b/addons/sale_journal/sale_journal.py index 8463ab3f3bd..cb33d7e2334 100644 --- a/addons/sale_journal/sale_journal.py +++ b/addons/sale_journal/sale_journal.py @@ -52,6 +52,10 @@ class res_partner(osv.osv): group_name = "Accounting Properties", help = "This invoicing type will be used, by default, to invoice the current partner."), } + + def _commercial_fields(self, cr, uid, context=None): + return super(res_partner, self)._commercial_fields(cr, uid, context=context) + ['property_invoice_type'] + res_partner() class picking(osv.osv): diff --git a/addons/sale_journal/sale_journal_view.xml b/addons/sale_journal/sale_journal_view.xml index bcd83b5be84..9d41103252e 100644 --- a/addons/sale_journal/sale_journal_view.xml +++ b/addons/sale_journal/sale_journal_view.xml @@ -146,7 +146,7 @@ - + diff --git a/addons/sale_stock/stock.py b/addons/sale_stock/stock.py index 93acf8579f5..b69a8a27ef6 100644 --- a/addons/sale_stock/stock.py +++ b/addons/sale_stock/stock.py @@ -53,7 +53,7 @@ class stock_picking(osv.osv): We select the partner of the sales order as the partner of the customer invoice """ if picking.sale_id: - return picking.sale_id.partner_id + return picking.sale_id.partner_invoice_id return super(stock_picking, self)._get_partner_to_invoice(cr, uid, picking, context=context) def _get_comment_invoice(self, cursor, user, picking): diff --git a/addons/sale_stock/test/picking_order_policy.yml b/addons/sale_stock/test/picking_order_policy.yml index 720c79685fa..09a8b73ffee 100644 --- a/addons/sale_stock/test/picking_order_policy.yml +++ b/addons/sale_stock/test/picking_order_policy.yml @@ -5,6 +5,12 @@ - !assert {model: sale.order, id: sale.sale_order_6, string: The amount of the Quotation is not correctly computed}: - sum([l.price_subtotal for l in order_line]) == amount_untaxed +- + I set an explicit invoicing partner that is different from the main SO Customer +- + !python {model: sale.order, id: sale.sale_order_6}: | + order = self.browse(cr, uid, ref("sale.sale_order_6")) + order.write({'partner_invoice_id': ref('base.res_partner_address_29')}) - I confirm the quotation with Invoice based on deliveries policy. - @@ -110,13 +116,13 @@ !python {model: sale.order}: | order = self.browse(cr, uid, ref("sale.sale_order_6")) assert order.invoice_ids, "Invoice is not created." - ac = order.partner_id.property_account_receivable.id + ac = order.partner_invoice_id.property_account_receivable.id journal_ids = self.pool.get('account.journal').search(cr, uid, [('type', '=', 'sale'), ('company_id', '=', order.company_id.id)]) for invoice in order.invoice_ids: assert invoice.type == 'out_invoice',"Invoice should be Customer Invoice." assert invoice.account_id.id == ac,"Invoice account is not correspond." assert invoice.reference == order.client_order_ref or order.name,"Reference is not correspond." - assert invoice.partner_id.id == order.partner_id.id,"Customer is not correspond." + assert invoice.partner_id.id == order.partner_invoice_id.id,"Customer does not correspond." assert invoice.currency_id.id == order.pricelist_id.currency_id.id, "Currency is not correspond." assert invoice.comment == (order.note or ''),"Note is not correspond." assert invoice.journal_id.id in journal_ids,"Sales Journal is not link on Invoice." diff --git a/addons/stock/report/report_stock_move_view.xml b/addons/stock/report/report_stock_move_view.xml index 4f3e256389c..fcf99f6e51e 100644 --- a/addons/stock/report/report_stock_move_view.xml +++ b/addons/stock/report/report_stock_move_view.xml @@ -149,7 +149,7 @@ - + diff --git a/addons/stock/stock_view.xml b/addons/stock/stock_view.xml index 14a1dca7dc7..83362ab5d6f 100644 --- a/addons/stock/stock_view.xml +++ b/addons/stock/stock_view.xml @@ -807,7 +807,7 @@ - + @@ -934,6 +934,7 @@ + @@ -1059,6 +1060,7 @@ + @@ -1370,7 +1372,7 @@ - +