Thomas Binsfeld
6 years ago
committed by
sbejaoui
27 changed files with 542 additions and 316 deletions
-
10contract/__manifest__.py
-
4contract/data/contract_cron.xml
-
2contract/data/contract_renew_cron.xml
-
2contract/data/mail_template.xml
-
145contract/migrations/12.0.4.0.0/post-migration.py
-
72contract/migrations/12.0.4.0.0/pre-migration.py
-
6contract/models/abstract_contract.py
-
6contract/models/abstract_contract_line.py
-
2contract/models/account_invoice.py
-
2contract/models/account_invoice_line.py
-
76contract/models/contract.py
-
42contract/models/contract_line.py
-
15contract/models/contract_template.py
-
10contract/models/contract_template_line.py
-
6contract/models/res_partner.py
-
2contract/report/contract_views.xml
-
2contract/report/report_contract.xml
-
2contract/security/contract_security.xml
-
14contract/security/ir.model.access.csv
-
109contract/tests/test_contract.py
-
10contract/views/abstract_contract_line.xml
-
156contract/views/contract.xml
-
75contract/views/contract_line.xml
-
42contract/views/contract_template.xml
-
16contract/views/contract_template_line.xml
-
6contract/wizards/contract_line_wizard.py
-
8contract/wizards/contract_line_wizard.xml
@ -0,0 +1,145 @@ |
|||||
|
# Copyright 2019 ACSONE SA/NV |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
|
||||
|
import logging |
||||
|
|
||||
|
from openupgradelib import openupgrade |
||||
|
|
||||
|
_logger = logging.getLogger(__name__) |
||||
|
|
||||
|
|
||||
|
def migrate(cr, version): |
||||
|
cr.execute( |
||||
|
""" |
||||
|
INSERT INTO contract_contract ( |
||||
|
id, |
||||
|
name, |
||||
|
partner_id, |
||||
|
pricelist_id, |
||||
|
contract_type, |
||||
|
journal_id, |
||||
|
company_id, |
||||
|
analytic_account_id, |
||||
|
active, |
||||
|
code, |
||||
|
group_id, |
||||
|
contract_template_id, |
||||
|
recurring_invoices, |
||||
|
user_id, |
||||
|
recurring_next_date, |
||||
|
date_end, |
||||
|
payment_term_id, |
||||
|
fiscal_position_id, |
||||
|
invoice_partner_id, |
||||
|
message_main_attachment_id, |
||||
|
create_uid, |
||||
|
create_date, |
||||
|
write_uid, |
||||
|
write_date |
||||
|
) |
||||
|
SELECT id, |
||||
|
name, |
||||
|
partner_id, |
||||
|
pricelist_id, |
||||
|
contract_type, |
||||
|
journal_id, |
||||
|
company_id, |
||||
|
id, |
||||
|
active, |
||||
|
code, |
||||
|
group_id, |
||||
|
contract_template_id, |
||||
|
recurring_invoices, |
||||
|
user_id, |
||||
|
recurring_next_date, |
||||
|
date_end, |
||||
|
payment_term_id, |
||||
|
fiscal_position_id, |
||||
|
invoice_partner_id, |
||||
|
message_main_attachment_id, |
||||
|
create_uid, |
||||
|
create_date, |
||||
|
write_uid, |
||||
|
write_date |
||||
|
FROM account_analytic_account |
||||
|
WHERE recurring_invoices = TRUE |
||||
|
""" |
||||
|
) |
||||
|
cr.execute( |
||||
|
""" |
||||
|
INSERT INTO contract_line ( |
||||
|
id, |
||||
|
product_id, |
||||
|
name, |
||||
|
quantity, |
||||
|
uom_id, |
||||
|
automatic_price, |
||||
|
specific_price, |
||||
|
discount, |
||||
|
recurring_rule_type, |
||||
|
recurring_invoicing_type, |
||||
|
recurring_interval, |
||||
|
sequence, |
||||
|
contract_id, |
||||
|
date_start, |
||||
|
date_end, |
||||
|
recurring_next_date, |
||||
|
last_date_invoiced, |
||||
|
termination_notice_date, |
||||
|
successor_contract_line_id, |
||||
|
predecessor_contract_line_id, |
||||
|
manual_renew_needed, |
||||
|
active, |
||||
|
create_uid, |
||||
|
create_date, |
||||
|
write_uid, |
||||
|
write_date |
||||
|
) |
||||
|
SELECT id, |
||||
|
product_id, |
||||
|
name, |
||||
|
quantity, |
||||
|
uom_id, |
||||
|
automatic_price, |
||||
|
specific_price, |
||||
|
discount, |
||||
|
recurring_rule_type, |
||||
|
recurring_invoicing_type, |
||||
|
recurring_interval, |
||||
|
sequence, |
||||
|
contract_id, |
||||
|
date_start, |
||||
|
date_end, |
||||
|
recurring_next_date, |
||||
|
last_date_invoiced, |
||||
|
termination_notice_date, |
||||
|
successor_contract_line_id, |
||||
|
predecessor_contract_line_id, |
||||
|
manual_renew_needed, |
||||
|
active, |
||||
|
create_uid, |
||||
|
create_date, |
||||
|
write_uid, |
||||
|
write_date |
||||
|
FROM account_analytic_invoice_line |
||||
|
""" |
||||
|
) |
||||
|
openupgrade.rename_models(cr, [('account.analytic.invoice.line', |
||||
|
'contract.line')]) |
||||
|
cr.execute( |
||||
|
""" |
||||
|
DROP TABLE account_analytic_invoice_line |
||||
|
""" |
||||
|
) |
||||
|
cr.execute( |
||||
|
""" |
||||
|
UPDATE account_invoice_line |
||||
|
SET contract_line_id = contract_line_id_tmp |
||||
|
""" |
||||
|
) |
||||
|
cr.execute( |
||||
|
""" |
||||
|
ALTER TABLE account_invoice_line |
||||
|
DROP COLUMN contract_line_id_tmp |
||||
|
""" |
||||
|
) |
@ -0,0 +1,72 @@ |
|||||
|
# Copyright 2019 ACSONE SA/NV |
||||
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). |
||||
|
|
||||
|
import logging |
||||
|
|
||||
|
from openupgradelib import openupgrade |
||||
|
|
||||
|
_logger = logging.getLogger(__name__) |
||||
|
|
||||
|
|
||||
|
def migrate(cr, version): |
||||
|
models_to_rename = [ |
||||
|
# Contract Line Wizard |
||||
|
('account.analytic.invoice.line.wizard', 'contract.line.wizard'), |
||||
|
# Abstract Contract |
||||
|
('account.abstract.analytic.contract', 'contract.abstract.contract'), |
||||
|
# Abstract Contract Line |
||||
|
('account.abstract.analytic.contract.line', |
||||
|
'contract.abstract.contract.line'), |
||||
|
# Contract Line |
||||
|
('account.analytic.invoice.line', 'contract.line'), |
||||
|
# Contract Template |
||||
|
('account.analytic.contract', 'contract.template'), |
||||
|
# Contract Template Line |
||||
|
('account.analytic.contract.line', 'contract.template.line'), |
||||
|
] |
||||
|
tables_to_rename = [ |
||||
|
# Contract Line Wizard |
||||
|
('account_analytic_invoice_line_wizard', 'contract_line_wizard'), |
||||
|
# Contract Template |
||||
|
('account_analytic_contract', 'contract_template'), |
||||
|
# Contract Template Line |
||||
|
('account_analytic_contract_line', 'contract_template_line'), |
||||
|
] |
||||
|
xmlids_to_rename = [ |
||||
|
('contract.account_analytic_cron_for_invoice', |
||||
|
'contract.contract_cron_for_invoice'), |
||||
|
('contract.account_analytic_contract_manager', |
||||
|
'contract.contract_template_manager'), |
||||
|
('contract.account_analytic_contract_user', |
||||
|
'contract.contract_template_user'), |
||||
|
('contract.account_analytic_invoice_line_manager', |
||||
|
'contract.contract_line_manager'), |
||||
|
('contract.account_analytic_invoice_line_user', |
||||
|
'contract.contract_line_user'), |
||||
|
('contract.account_analytic_contract_line_manager', |
||||
|
'contract.contract_template_line_manager'), |
||||
|
('contract.account_analytic_contract_line_user', |
||||
|
'contract.contract_template_line_user'), |
||||
|
] |
||||
|
openupgrade.rename_models(cr, models_to_rename) |
||||
|
openupgrade.rename_tables(cr, tables_to_rename) |
||||
|
openupgrade.rename_xmlids(cr, xmlids_to_rename) |
||||
|
# A temporary column is needed to avoid breaking the foreign key constraint |
||||
|
# The temporary column is dropped in the post-migration script |
||||
|
cr.execute( |
||||
|
""" |
||||
|
ALTER TABLE account_invoice_line |
||||
|
ADD COLUMN contract_line_id_tmp INTEGER |
||||
|
""" |
||||
|
) |
||||
|
cr.execute( |
||||
|
""" |
||||
|
UPDATE account_invoice_line |
||||
|
SET contract_line_id_tmp = contract_line_id |
||||
|
""" |
||||
|
) |
||||
|
cr.execute( |
||||
|
""" |
||||
|
UPDATE account_invoice_line SET contract_line_id = NULL |
||||
|
""" |
||||
|
) |
@ -1,7 +1,9 @@ |
|||||
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" |
"id","name","model_id:id","group_id:id","perm_read","perm_write","perm_create","perm_unlink" |
||||
"account_analytic_contract_manager","Recurring manager","model_account_analytic_contract","account.group_account_manager",1,1,1,1 |
|
||||
"account_analytic_contract_user","Recurring user","model_account_analytic_contract","account.group_account_invoice",1,0,0,0 |
|
||||
"account_analytic_invoice_line_manager","Recurring manager","model_account_analytic_invoice_line","account.group_account_manager",1,1,1,1 |
|
||||
"account_analytic_invoice_line_user","Recurring user","model_account_analytic_invoice_line","account.group_account_invoice",1,0,0,0 |
|
||||
"account_analytic_contract_line_manager","Recurring manager","model_account_analytic_contract_line","account.group_account_manager",1,1,1,1 |
|
||||
"account_analytic_contract_line_user","Recurring user","model_account_analytic_contract_line","account.group_account_invoice",1,0,0,0 |
|
||||
|
"contract_template_manager","Recurring manager","model_contract_template","account.group_account_manager",1,1,1,1 |
||||
|
"contract_template_user","Recurring user","model_contract_template","account.group_account_invoice",1,0,0,0 |
||||
|
"contract_manager","Recurring manager","model_contract_contract","account.group_account_manager",1,1,1,1 |
||||
|
"contract_user","Recurring user","model_contract_contract","account.group_account_invoice",1,0,0,0 |
||||
|
"contract_line_manager","Recurring manager","model_contract_line","account.group_account_manager",1,1,1,1 |
||||
|
"contract_line_user","Recurring user","model_contract_line","account.group_account_invoice",1,0,0,0 |
||||
|
"contract_template_line_manager","Recurring manager","model_contract_template_line","account.group_account_manager",1,1,1,1 |
||||
|
"contract_template_line_user","Recurring user","model_contract_template_line","account.group_account_invoice",1,0,0,0 |
@ -1,16 +1,16 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
<?xml version="1.0" encoding="utf-8"?> |
||||
<odoo> |
<odoo> |
||||
|
|
||||
<record id="account_analytic_contract_line_view_form" model="ir.ui.view"> |
|
||||
<field name="name">account.analytic.contract.line.form</field> |
|
||||
<field name="model">account.analytic.contract.line</field> |
|
||||
<field name="inherit_id" |
|
||||
ref="account_abstract_analytic_contract_line_view_form"/> |
|
||||
|
<!--FORM view--> |
||||
|
<record id="contract_template_line_form_view" model="ir.ui.view"> |
||||
|
<field name="name">contract.template.line form view (in contract)</field> |
||||
|
<field name="model">contract.template.line</field> |
||||
|
<field name="inherit_id" ref="contract_abstract_contract_line_form_view"/> |
||||
<field name="mode">primary</field> |
<field name="mode">primary</field> |
||||
<field name="arch" type="xml"> |
<field name="arch" type="xml"> |
||||
<xpath expr="//form" position="attributes"> |
|
||||
<attribute name="string">Contract Line Template</attribute> |
|
||||
</xpath> |
|
||||
|
<form position="attributes"> |
||||
|
<attribute name="string">Contract Template Line</attribute> |
||||
|
</form> |
||||
</field> |
</field> |
||||
</record> |
</record> |
||||
|
|
||||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue