跳至内容
菜单
此问题已终结
3728 查看


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

形象
丢弃
编写者

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.

相关帖文 回复 查看 活动
3
2月 25
3529
0
5月 24
46
1
4月 24
3343
4
9月 23
4828
2
9月 23
7038