mirror of
https://github.com/OCA/contract.git
synced 2025-02-13 17:57:24 +02:00
@@ -184,6 +184,7 @@ class ContractAbstractContractLine(models.AbstractModel):
|
|||||||
"quantity",
|
"quantity",
|
||||||
"contract_id.pricelist_id",
|
"contract_id.pricelist_id",
|
||||||
"contract_id.partner_id",
|
"contract_id.partner_id",
|
||||||
|
"uom_id",
|
||||||
)
|
)
|
||||||
def _compute_price_unit(self):
|
def _compute_price_unit(self):
|
||||||
"""Get the specific price if no auto-price, and the price obtained
|
"""Get the specific price if no auto-price, and the price obtained
|
||||||
@@ -207,6 +208,7 @@ class ContractAbstractContractLine(models.AbstractModel):
|
|||||||
date=line.env.context.get(
|
date=line.env.context.get(
|
||||||
"old_date", fields.Date.context_today(line)
|
"old_date", fields.Date.context_today(line)
|
||||||
),
|
),
|
||||||
|
uom=line.uom_id.id,
|
||||||
)
|
)
|
||||||
line.price_unit = product.price
|
line.price_unit = product.price
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -2401,3 +2401,17 @@ class TestContract(TestContractBase):
|
|||||||
action = self.contract.action_preview()
|
action = self.contract.action_preview()
|
||||||
self.assertIn("/my/contracts/", action["url"])
|
self.assertIn("/my/contracts/", action["url"])
|
||||||
self.assertIn("access_token=", action["url"])
|
self.assertIn("access_token=", action["url"])
|
||||||
|
|
||||||
|
def test_automatic_price_with_specific_uom(self):
|
||||||
|
uom_hour = self.env.ref("uom.product_uom_hour")
|
||||||
|
uom_day = self.env.ref("uom.product_uom_day")
|
||||||
|
# Set automatic price on contract line
|
||||||
|
self.acct_line.automatic_price = True
|
||||||
|
# Check UOM from contract line and product and product price to be the same
|
||||||
|
self.assertEqual(self.product_1.uom_id, uom_hour)
|
||||||
|
self.assertEqual(self.acct_line.uom_id, uom_hour)
|
||||||
|
self.assertEqual(self.acct_line.price_unit, 30.75)
|
||||||
|
# Check UOM update and price in contract line
|
||||||
|
self.acct_line.uom_id = uom_day.id
|
||||||
|
self.acct_line.refresh()
|
||||||
|
self.assertEqual(self.acct_line.price_unit, 30.75 * 8)
|
||||||
|
|||||||
Reference in New Issue
Block a user