Skip to content

Commit

Permalink
[MIG] contract: Migration to 12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sbejaoui committed Oct 26, 2018
1 parent 2eec353 commit a17a89b
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 44 deletions.
2 changes: 1 addition & 1 deletion contract/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

{
'name': 'Contracts Management - Recurring',
'version': '11.0.4.0.0',
'version': '12.0.1.0.0',
'category': 'Contract Management',
'license': 'AGPL-3',
'author': "OpenERP SA, "
Expand Down
18 changes: 0 additions & 18 deletions contract/migrations/11.0.2.0.0/pre-migration.py

This file was deleted.

2 changes: 1 addition & 1 deletion contract/models/account_analytic_contract_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class AccountAnalyticContractLine(models.Model):
required=True,
)
uom_id = fields.Many2one(
'product.uom',
'uom.uom',
string='Unit of Measure',
required=True,
)
Expand Down
1 change: 1 addition & 0 deletions contract/readme/CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
* Dave Lasley <dave@laslabs.com>
* Vicent Cubells <vicent.cubells@tecnativa.com>
* Miquel Raïch <miquel.raich@eficent.com>
* Souheil Bejaoui <souheil.bejaoui@acsone.eu>
40 changes: 25 additions & 15 deletions contract/tests/test_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def test_automatic_price(self):
self.assertEqual(self.acct_line.price_unit, 10)

def test_contract(self):
recurring_next_date = fields.Date.to_date('2016-03-29')
self.assertAlmostEqual(self.acct_line.price_subtotal, 50.0)
res = self.acct_line._onchange_product_id()
self.assertIn('uom_id', res['domain'])
Expand All @@ -101,24 +102,28 @@ def test_contract(self):
self.invoice_monthly = self.env['account.invoice'].search(
[('contract_id', '=', self.contract.id)])
self.assertTrue(self.invoice_monthly)
self.assertEqual(self.contract.recurring_next_date, '2016-03-29')
self.assertEqual(self.contract.recurring_next_date,
recurring_next_date)
self.inv_line = self.invoice_monthly.invoice_line_ids[0]
self.assertTrue(self.inv_line.invoice_line_tax_ids)
self.assertAlmostEqual(self.inv_line.price_subtotal, 50.0)
self.assertEqual(self.contract.partner_id.user_id,
self.invoice_monthly.user_id)

def test_contract_daily(self):
recurring_next_date = fields.Date.to_date('2016-03-01')
self.contract.recurring_next_date = '2016-02-29'
self.contract.recurring_rule_type = 'daily'
self.contract.pricelist_id = False
self.contract.cron_recurring_create_invoice()
invoice_daily = self.env['account.invoice'].search(
[('contract_id', '=', self.contract.id)])
self.assertTrue(invoice_daily)
self.assertEqual(self.contract.recurring_next_date, '2016-03-01')
self.assertEqual(self.contract.recurring_next_date,
recurring_next_date)

def test_contract_weekly(self):
recurring_next_date = fields.Date.to_date('2016-03-07')
self.contract.recurring_next_date = '2016-02-29'
self.contract.recurring_rule_type = 'weekly'
self.contract.recurring_invoicing_type = 'post-paid'
Expand All @@ -127,41 +132,45 @@ def test_contract_weekly(self):
[('contract_id', '=', self.contract.id)])
self.assertTrue(invoices_weekly)
self.assertEqual(
self.contract.recurring_next_date, '2016-03-07')
self.contract.recurring_next_date, recurring_next_date)

def test_contract_yearly(self):
recurring_next_date = fields.Date.to_date('2017-02-28')
self.contract.recurring_next_date = '2016-02-29'
self.contract.recurring_rule_type = 'yearly'
self.contract.recurring_create_invoice()
invoices_weekly = self.env['account.invoice'].search(
[('contract_id', '=', self.contract.id)])
self.assertTrue(invoices_weekly)
self.assertEqual(
self.contract.recurring_next_date, '2017-02-28')
self.contract.recurring_next_date, recurring_next_date)

def test_contract_monthly_lastday(self):
recurring_next_date = fields.Date.to_date('2016-03-31')
self.contract.recurring_next_date = '2016-02-29'
self.contract.recurring_invoicing_type = 'post-paid'
self.contract.recurring_rule_type = 'monthlylastday'
self.contract.recurring_create_invoice()
invoices_monthly_lastday = self.env['account.invoice'].search(
[('contract_id', '=', self.contract.id)])
self.assertTrue(invoices_monthly_lastday)
self.assertEqual(self.contract.recurring_next_date, '2016-03-31')
self.assertEqual(self.contract.recurring_next_date,
recurring_next_date)

def test_onchange_partner_id(self):
self.contract._onchange_partner_id()
self.assertEqual(self.contract.pricelist_id,
self.contract.partner_id.property_product_pricelist)

def test_onchange_date_start(self):
date = '2016-01-01'
self.contract.date_start = date
recurring_next_date = fields.Date.to_date('2016-01-01')
self.contract.date_start = recurring_next_date
self.contract._onchange_date_start()
self.assertEqual(self.contract.recurring_next_date, date)
self.assertEqual(self.contract.recurring_next_date,
recurring_next_date)

def test_uom(self):
uom_litre = self.env.ref('product.product_uom_litre')
uom_litre = self.env.ref('uom.product_uom_litre')
self.acct_line.uom_id = uom_litre.id
self.acct_line._onchange_product_id()
self.assertEqual(self.acct_line.uom_id,
Expand Down Expand Up @@ -273,9 +282,9 @@ def test_contract_onchange_product_id_domain(self):
def test_contract_onchange_product_id_uom(self):
"""It should update the UoM for the line."""
line = self._add_template_line(
{'uom_id': self.env.ref('product.product_uom_litre').id}
{'uom_id': self.env.ref('uom.product_uom_litre').id}
)
line.product_id.uom_id = self.env.ref('product.product_uom_day').id
line.product_id.uom_id = self.env.ref('uom.product_uom_day').id
line._onchange_product_id()
self.assertEqual(line.uom_id,
line.product_id.uom_id)
Expand All @@ -292,13 +301,14 @@ def test_contract_onchange_product_id_name(self):

def test_contract_count(self):
"""It should return sale contract count."""
count = self.partner.sale_contract_count + 2
sale_count = self.partner.sale_contract_count + 2
self.contract.copy()
self.contract.copy()
self.assertEqual(self.partner.sale_contract_count, count)
count = self.partner.purchase_contract_count + 1
purchase_count = self.partner.purchase_contract_count + 1
self.contract2.copy()
self.assertEqual(self.partner.purchase_contract_count, count)
self.partner.refresh()
self.assertEqual(self.partner.sale_contract_count, sale_count)
self.assertEqual(self.partner.purchase_contract_count, purchase_count)

def test_same_date_start_and_date_end(self):
"""It should create one invoice with same start and end date."""
Expand Down
10 changes: 6 additions & 4 deletions contract/views/account_analytic_account_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,13 @@
domain="[('date_end', '&lt;', time.strftime('%Y-%m-%d'))]"
/>
<group expand="0" string="Group By...">
<filter string="Next Invoice"
<filter name="next_invoice"
string="Next Invoice"
domain="[]"
context="{'group_by':'recurring_next_date'}"
/>
<filter string="Date End"
<filter name="date_end"
string="Date End"
domain="[]"
context="{'group_by':'date_end'}"
/>
Expand Down Expand Up @@ -232,7 +234,7 @@
</record>

<menuitem id="menu_action_account_analytic_sale_overdue_all"
parent="account.menu_finance_receivables_documents"
parent="account.menu_finance_receivables"
action="action_account_analytic_sale_overdue_all"
sequence="99"
/>
Expand Down Expand Up @@ -268,7 +270,7 @@
</record>

<menuitem id="menu_action_account_analytic_purchase_overdue_all"
parent="account.menu_finance_payables_documents"
parent="account.menu_finance_payables"
action="action_account_analytic_purchase_overdue_all"
sequence="99"
/>
Expand Down
15 changes: 10 additions & 5 deletions contract/views/account_analytic_contract_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,24 @@
<field name="recurring_invoicing_type" />
<field name="pricelist_id" />
<field name="journal_id" />
<filter string="Contract Type"
<filter name="contract_type"
string="Contract Type"
context="{'group_by': 'contract_type'}"
/>
<filter string="Recurrence"
<filter name="recurring_rule_type"
string="Recurrence"
context="{'group_by': 'recurring_rule_type'}"
/>
<filter string="Invoicing type"
<filter name="recurring_invoicing_type"
string="Invoicing type"
context="{'group_by': 'recurring_invoicing_type'}"
/>
<filter string="Pricelist"
<filter name="pricelist_id"
string="Pricelist"
context="{'group_by': 'pricelist_id'}"
/>
<filter string="Journal"
<filter name="journal_id"
string="Journal"
context="{'group_by': 'journal_id'}"
/>
</search>
Expand Down

0 comments on commit a17a89b

Please sign in to comment.