Hi ,
I want to get value of standard_price of the main company in compute field of standard_price.
I tried with this code but showing always 'False' value.
Any help please ??
Here is my code:
class ProductTemplate(models.Model):
_inherit = "product.template"
@api.depends_context('company')
@api.depends('product_variant_ids', 'product_variant_ids.standard_price')
def _compute_standard_price(self):
st_price = self.env['ir.property']._get(self.with_context(company=self.env.ref('base.main_company')).standard_price,"product.product")
_logger.info('------st_price:%s', st_price)
# Depends on force_company context because standard_price is company_dependent
# on the product_product
unique_variants = self.filtered(lambda template: len(template.product_variant_ids) == 1)
for template in unique_variants:
template.standard_price = template.product_variant_ids.standard_price
for template in (self - unique_variants):
template.standard_price = 0.0
***Result : ------st_price:False
Thanks
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Účetnictví
- Sklad
- PoS
- Project
- MRP
This question has been flagged
3717
Zobrazení
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Přihlásit seRelated Posts | Odpovědi | Zobrazení | Aktivita | |
---|---|---|---|---|
|
3
úno 25
|
3503 | ||
|
0
kvě 24
|
46 | ||
|
1
dub 24
|
3330 | ||
|
4
zář 23
|
4818 | ||
|
2
zář 23
|
7032 |
The main objective was : I have company A with Inventory valuation configuration (avco/automated) and company B with Inventory valuation configuration (standard/manual) If I have standard_price value in company A,when I switch from company A to B, I want to get same value in company B , actually I get always 0.0 value.