mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[FIX] contract: Handle properly multi-company setups
If you have contracts in several companies, cron will create all of them, but property fields will be populated with incorrect data as the taken company is the main from the cron user (usually admin).
This commit is contained in:
committed by
Francisco Ivan Anton Prieto
parent
d39629a1ef
commit
46b8715806
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
'name': 'Recurring - Contracts Management',
|
'name': 'Recurring - Contracts Management',
|
||||||
'version': '12.0.5.1.3',
|
'version': '12.0.5.2.0',
|
||||||
'category': 'Contract Management',
|
'category': 'Contract Management',
|
||||||
'license': 'AGPL-3',
|
'license': 'AGPL-3',
|
||||||
'author': "OpenERP SA, "
|
'author': "OpenERP SA, "
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ msgid "Cancel allowed?"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: code:addons/contract/models/contract_line.py:1054
|
#: code:addons/contract/models/contract_line.py:1056
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Cancel not allowed for this line"
|
msgid "Cancel not allowed for this line"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -305,7 +305,7 @@ msgid "Company"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: code:addons/contract/models/contract.py:318
|
#: code:addons/contract/models/contract.py:321
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Compose Email"
|
msgid "Compose Email"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -398,7 +398,7 @@ msgid "Contract line '%s' start date can't be later than end date"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: code:addons/contract/models/contract_line.py:1083
|
#: code:addons/contract/models/contract_line.py:1085
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Contract line Un-canceled: %s<br/>- "
|
msgid "Contract line Un-canceled: %s<br/>- "
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -416,13 +416,13 @@ msgid "Contract line and its successor overlapped"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: code:addons/contract/models/contract_line.py:1062
|
#: code:addons/contract/models/contract_line.py:1064
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Contract line canceled: %s<br/>- "
|
msgid "Contract line canceled: %s<br/>- "
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: code:addons/contract/models/contract_line.py:854
|
#: code:addons/contract/models/contract_line.py:856
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Contract line for <strong>{product}</strong>\n"
|
msgid "Contract line for <strong>{product}</strong>\n"
|
||||||
" stopped: <br/>\n"
|
" stopped: <br/>\n"
|
||||||
@@ -431,7 +431,7 @@ msgid "Contract line for <strong>{product}</strong>\n"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: code:addons/contract/models/contract_line.py:934
|
#: code:addons/contract/models/contract_line.py:936
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Contract line for <strong>{product}</strong>\n"
|
msgid "Contract line for <strong>{product}</strong>\n"
|
||||||
" planned a successor: <br/>\n"
|
" planned a successor: <br/>\n"
|
||||||
@@ -442,7 +442,7 @@ msgid "Contract line for <strong>{product}</strong>\n"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: code:addons/contract/models/contract_line.py:1230
|
#: code:addons/contract/models/contract_line.py:1232
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Contract line for <strong>{product}</strong>\n"
|
msgid "Contract line for <strong>{product}</strong>\n"
|
||||||
" renewed: <br/>\n"
|
" renewed: <br/>\n"
|
||||||
@@ -453,7 +453,7 @@ msgid "Contract line for <strong>{product}</strong>\n"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: code:addons/contract/models/contract_line.py:1042
|
#: code:addons/contract/models/contract_line.py:1044
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Contract line for <strong>{product}</strong>\n"
|
msgid "Contract line for <strong>{product}</strong>\n"
|
||||||
" suspended: <br/>\n"
|
" suspended: <br/>\n"
|
||||||
@@ -464,7 +464,7 @@ msgid "Contract line for <strong>{product}</strong>\n"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: code:addons/contract/models/contract_line.py:1280
|
#: code:addons/contract/models/contract_line.py:1282
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Contract line must be canceled before delete"
|
msgid "Contract line must be canceled before delete"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -986,7 +986,7 @@ msgid "Plan successor allowed?"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: code:addons/contract/models/contract_line.py:917
|
#: code:addons/contract/models/contract_line.py:919
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Plan successor not allowed for this line"
|
msgid "Plan successor not allowed for this line"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -997,7 +997,7 @@ msgid "Planned"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: code:addons/contract/models/contract.py:273
|
#: code:addons/contract/models/contract.py:274
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Please define a %s journal for the company '%s'."
|
msgid "Please define a %s journal for the company '%s'."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1208,7 +1208,7 @@ msgid "Stop allowed?"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: code:addons/contract/models/contract_line.py:837
|
#: code:addons/contract/models/contract_line.py:839
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Stop not allowed for this line"
|
msgid "Stop not allowed for this line"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1219,7 +1219,7 @@ msgid "Stop/Plan successor allowed?"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: code:addons/contract/models/contract_line.py:978
|
#: code:addons/contract/models/contract_line.py:980
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Stop/Plan successor not allowed for this line"
|
msgid "Stop/Plan successor not allowed for this line"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1311,7 +1311,7 @@ msgid "Un-cancel"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: code:addons/contract/models/contract_line.py:1075
|
#: code:addons/contract/models/contract_line.py:1077
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Un-cancel not allowed for this line"
|
msgid "Un-cancel not allowed for this line"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -1402,7 +1402,7 @@ msgid "Year(s)"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#. module: contract
|
#. module: contract
|
||||||
#: code:addons/contract/models/contract_line.py:787
|
#: code:addons/contract/models/contract_line.py:789
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "You can't delay a contract line invoiced at least one time."
|
msgid "You can't delay a contract line invoiced at least one time."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
@@ -283,7 +283,9 @@ class ContractContract(models.Model):
|
|||||||
invoice_type = 'out_invoice'
|
invoice_type = 'out_invoice'
|
||||||
if self.contract_type == 'purchase':
|
if self.contract_type == 'purchase':
|
||||||
invoice_type = 'in_invoice'
|
invoice_type = 'in_invoice'
|
||||||
vinvoice = self.env['account.invoice'].new({
|
vinvoice = self.env['account.invoice'].with_context(
|
||||||
|
force_company=self.company_id.id,
|
||||||
|
).new({
|
||||||
'partner_id': self.invoice_partner_id.id,
|
'partner_id': self.invoice_partner_id.id,
|
||||||
'type': invoice_type,
|
'type': invoice_type,
|
||||||
})
|
})
|
||||||
@@ -345,7 +347,9 @@ class ContractContract(models.Model):
|
|||||||
# taken from the invoice's journal in _onchange_product_id
|
# taken from the invoice's journal in _onchange_product_id
|
||||||
# This code is not in finalize_creation_from_contract because it's
|
# This code is not in finalize_creation_from_contract because it's
|
||||||
# not possible to create an invoice line with no account
|
# not possible to create an invoice line with no account
|
||||||
new_invoice = self.env['account.invoice'].new(invoice_values)
|
new_invoice = self.env['account.invoice'].with_context(
|
||||||
|
force_company=invoice_values['company_id'],
|
||||||
|
).new(invoice_values)
|
||||||
for invoice_line in new_invoice.invoice_line_ids:
|
for invoice_line in new_invoice.invoice_line_ids:
|
||||||
name = invoice_line.name
|
name = invoice_line.name
|
||||||
account_analytic_id = invoice_line.account_analytic_id
|
account_analytic_id = invoice_line.account_analytic_id
|
||||||
|
|||||||
@@ -658,7 +658,9 @@ class ContractLine(models.Model):
|
|||||||
}
|
}
|
||||||
if invoice_id:
|
if invoice_id:
|
||||||
invoice_line_vals['invoice_id'] = invoice_id.id
|
invoice_line_vals['invoice_id'] = invoice_id.id
|
||||||
invoice_line = self.env['account.invoice.line'].new(invoice_line_vals)
|
invoice_line = self.env['account.invoice.line'].with_context(
|
||||||
|
force_company=self.contract_id.company_id.id,
|
||||||
|
).new(invoice_line_vals)
|
||||||
# Get other invoice line values from product onchange
|
# Get other invoice line values from product onchange
|
||||||
invoice_line._onchange_product_id()
|
invoice_line._onchange_product_id()
|
||||||
invoice_line_vals = invoice_line._convert_to_write(invoice_line._cache)
|
invoice_line_vals = invoice_line._convert_to_write(invoice_line._cache)
|
||||||
|
|||||||
Reference in New Issue
Block a user