콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3343 화면

I created a small module

 

class ProducctCottonPrice(models.Model):
_inherit = 'product.template'

cotton_qty = fields.Float(string='PCS in Cotton', digits=0, default=1.0)
@api.one
@api.onchange('cotton_qty')
def _compute_po_id(self):
for p in self:
if p.cotton_qty <= 1.0:
p.uom_po_id = p.uom_id
elif p.cotton_qty > 1:
p.uom_po_id = self.env['product.uom'].search([('factor_inv', '=', p.cotton_qty)] limit=1)

elif p.cotton_qty > 1.0:
p.uom_po_id = self.env['product.uom'].create(
{
'name': Cotton + ' ' + p.cotton_qty,
'category_id': p.uom_id,
'uom_type': bigger,
'factor_inv': p.cotton_qty,
'active': True,
'rounding': 1 / p.cotton_qty,
}
)
but if I have a product.uom_id.factor_inv = p.cotton_qty
It still do not pick the value and through me an error.
attributeerror: 'list' object has no attribute 'get'
아바타
취소
관련 게시물 답글 화면 활동
5
10월 15
10436
2
7월 22
7973
3
6월 16
6249
1
11월 22
2411
2
5월 25
1357