Skip to content

Commit

Permalink
[MIG] contract_sale_generation: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusValdez96 committed May 28, 2023
1 parent 6876de0 commit 22c255f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion contract_sale_generation/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{
"name": "Contracts Management - Recurring Sales",
"version": "15.0.1.0.3",
"version": "16.0.1.0.0",
"category": "Contract Management",
"license": "AGPL-3",
"author": "ACSONE SA/NV, PESOL, Odoo Community Association (OCA)",
Expand Down
8 changes: 6 additions & 2 deletions contract_sale_generation/models/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ def _prepare_sale(self, date_ref):
sale.payment_term_id = self.payment_term_id.id
if self.fiscal_position_id:
sale.fiscal_position_id = self.fiscal_position_id.id
# Get other sale values from partner onchange
sale.onchange_partner_id()
# Get other sale values
sale._compute_partner_shipping_id()
sale._compute_pricelist_id()
sale._compute_currency_rate()
sale._compute_user_id()
sale._compute_team_id()
return sale._convert_to_write(sale._cache)

def _get_related_sales(self):
Expand Down
5 changes: 2 additions & 3 deletions contract_sale_generation/models/contract_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def _prepare_sale_line_vals(self, dates, order_id=False):
sale_line_vals = {
"product_id": self.product_id.id,
"product_uom_qty": self._get_quantity_to_invoice(*dates),
"product_uom": self.uom_id.id,
"product_uom": self.product_id.uom_id.id,
"discount": self.discount,
"contract_line_id": self.id,
"display_type": self.display_type,
Expand Down Expand Up @@ -40,15 +40,14 @@ def _prepare_sale_line(self, order_id=False, sale_values=False):
)
order_line.order_id = sale
# Get other order line values from product onchange
order_line.product_id_change()
order_line._onchange_product_id_warning()
sale_line_vals = order_line._convert_to_write(order_line._cache)
# Insert markers
name = self._insert_markers(dates[0], dates[1])
sale_line_vals.update(
{
"sequence": self.sequence,
"name": name,
"analytic_tag_ids": [(6, 0, self.analytic_tag_ids.ids)],
"price_unit": self.price_unit,
}
)
Expand Down
21 changes: 9 additions & 12 deletions contract_sale_generation/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def setUpClass(cls):
cls.analytic_account = cls.env["account.analytic.account"].create(
{
"name": "Contracts",
"plan_id": cls.env.ref("analytic.analytic_plan_internal").id,
}
)
cls.payment_term_id = cls.env.ref(
Expand All @@ -30,7 +31,7 @@ def setUpClass(cls):
cls.fiscal_position_id = cls.env["account.fiscal.position"].create(
{"name": "Contracts"}
)
contract_date = "2020-01-15"
contract_date = "2020-01-01"
cls.pricelist = cls.env["product.pricelist"].create(
{
"name": "pricelist for contract test",
Expand Down Expand Up @@ -58,6 +59,7 @@ def setUpClass(cls):
"discount": 50,
"recurring_rule_type": "yearly",
"recurring_interval": 1,
"display_type": False,
}
cls.template_vals = {
"name": "Test Contract Template",
Expand All @@ -84,31 +86,25 @@ def setUpClass(cls):
"generation_type": "sale",
"sale_autoconfirm": False,
"group_id": cls.analytic_account.id,
"date_start": "2020-01-15",
"date_start": "2020-01-01",
}
)
cls.line_vals = {
"name": "Services from #START# to #END#",
"product_id": cls.product_1.id,
"uom_id": cls.product_1.uom_id.id,
"quantity": 1,
"price_unit": 100,
"discount": 50,
"recurring_rule_type": "monthly",
"recurring_interval": 1,
"date_start": "2020-01-01",
"recurring_next_date": "2020-01-15",
"display_type": False,
}
with Form(cls.contract) as contract_form, freeze_time(contract_date):
contract_form.contract_template_id = cls.template
with contract_form.contract_line_ids.new() as line_form:
line_form.product_id = cls.product_1
line_form.name = "Services from #START# to #END#"
line_form.quantity = 1
line_form.price_unit = 100.0
line_form.discount = 50
line_form.recurring_rule_type = "monthly"
line_form.recurring_interval = 1
line_form.date_start = "2020-01-15"
line_form.recurring_next_date = "2020-01-15"
cls.contract.write({"contract_line_ids": [(0, 0, cls.line_vals)]})
cls.contract_line = cls.contract.contract_line_ids[1]

cls.contract2 = cls.env["contract.contract"].create(
Expand All @@ -133,6 +129,7 @@ def setUpClass(cls):
"recurring_interval": 1,
"date_start": "2018-02-15",
"recurring_next_date": "2018-02-22",
"display_type": False,
},
)
],
Expand Down
1 change: 1 addition & 0 deletions contract_sale_generation/tests/test_contract_sale.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def test_onchange_contract_template_id(self):
"discount": 50,
"recurring_rule_type": "yearly",
"recurring_interval": 1,
"display_type": False,
},
)
],
Expand Down

0 comments on commit 22c255f

Please sign in to comment.