mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
[MIG] contract: Migration to 14.0
This commit is contained in:
committed by
Pedro M. Baeza
parent
ae6a8179b7
commit
86ed1e128c
@@ -186,8 +186,8 @@ class ContractAbstractContractLine(models.AbstractModel):
|
||||
if line.automatic_price:
|
||||
pricelist = (
|
||||
line.contract_id.pricelist_id
|
||||
or line.contract_id.partner_id.with_context(
|
||||
force_company=line.contract_id.company_id.id,
|
||||
or line.contract_id.partner_id.with_company(
|
||||
line.contract_id.company_id
|
||||
).property_product_pricelist
|
||||
)
|
||||
product = line.product_id.with_context(
|
||||
|
||||
@@ -239,8 +239,8 @@ class ContractContract(models.Model):
|
||||
# Use pricelist currency
|
||||
currency = (
|
||||
self.pricelist_id.currency_id
|
||||
or self.partner_id.with_context(
|
||||
force_company=self.company_id.id,
|
||||
or self.partner_id.with_company(
|
||||
self.company_id
|
||||
).property_product_pricelist.currency_id
|
||||
)
|
||||
return currency or self.journal_id.currency_id or self.company_id.currency_id
|
||||
@@ -360,7 +360,7 @@ class ContractContract(models.Model):
|
||||
partner = (
|
||||
self.partner_id
|
||||
if not self.company_id
|
||||
else self.partner_id.with_context(force_company=self.company_id.id)
|
||||
else self.partner_id.with_company(self.company_id)
|
||||
)
|
||||
self.pricelist_id = partner.property_product_pricelist.id
|
||||
self.fiscal_position_id = partner.env[
|
||||
@@ -423,9 +423,9 @@ class ContractContract(models.Model):
|
||||
if self.contract_type == "purchase":
|
||||
invoice_type = "in_invoice"
|
||||
move_form = Form(
|
||||
self.env["account.move"].with_context(
|
||||
force_company=self.company_id.id, default_type=invoice_type
|
||||
)
|
||||
self.env["account.move"]
|
||||
.with_company(self.company_id)
|
||||
.with_context(default_move_type=invoice_type)
|
||||
)
|
||||
move_form.partner_id = self.invoice_partner_id
|
||||
if self.payment_term_id:
|
||||
@@ -491,11 +491,11 @@ class ContractContract(models.Model):
|
||||
"""
|
||||
self.ensure_one()
|
||||
|
||||
def can_be_invoiced(l):
|
||||
def can_be_invoiced(contract_line):
|
||||
return (
|
||||
not l.is_canceled
|
||||
and l.recurring_next_date
|
||||
and l.recurring_next_date <= date_ref
|
||||
not contract_line.is_canceled
|
||||
and contract_line.recurring_next_date
|
||||
and contract_line.recurring_next_date <= date_ref
|
||||
)
|
||||
|
||||
lines2invoice = previous = self.env["contract.line"]
|
||||
|
||||
@@ -382,7 +382,10 @@ class ContractLine(models.Model):
|
||||
@api.constrains("predecessor_contract_line_id", "date_start")
|
||||
def _check_overlap_predecessor(self):
|
||||
for rec in self:
|
||||
if rec.predecessor_contract_line_id:
|
||||
if (
|
||||
rec.predecessor_contract_line_id
|
||||
and rec.predecessor_contract_line_id.date_end
|
||||
):
|
||||
if rec.date_start <= rec.predecessor_contract_line_id.date_end:
|
||||
raise ValidationError(
|
||||
_("Contract line and its predecessor overlapped")
|
||||
|
||||
@@ -71,10 +71,10 @@ class ResPartner(models.Model):
|
||||
|
||||
def _get_act_window_contract_xml(self, contract_type):
|
||||
if contract_type == "purchase":
|
||||
return self.env["ir.actions.act_window"].for_xml_id(
|
||||
"contract", "action_supplier_contract"
|
||||
return self.env["ir.actions.act_window"]._for_xml_id(
|
||||
"contract.action_supplier_contract"
|
||||
)
|
||||
else:
|
||||
return self.env["ir.actions.act_window"].for_xml_id(
|
||||
"contract", "action_customer_contract"
|
||||
return self.env["ir.actions.act_window"]._for_xml_id(
|
||||
"contract.action_customer_contract"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user