Skip to Content
Menú
This question has been flagged
3706 Vistes


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

Avatar
Descartar
Autor

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.

Related Posts Respostes Vistes Activitat
3
de febr. 25
3463
0
de maig 24
46
1
d’abr. 24
3320
4
de set. 23
4805
2
de set. 23
7022