Merge PR #826 into 14.0

Signed-off-by rousseldenis
This commit is contained in:
OCA-git-bot
2022-08-09 10:04:46 +00:00
2 changed files with 16 additions and 0 deletions

View File

@@ -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:

View File

@@ -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)