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

In approvals app, when I create a new RFQ (new request), I inherited the view and added smart button to it in addition to a many2one field(purchase_agreement_id) taken from the model purchase.requisition in order to take the purchase id and fill the one2many field below it. What I want to do, is when pressing on the smart button, it will be responsible for taking me from the current form to another form and sending along it the products filled in my one2many field. I have already made a code that is responsible for filling the one2many field when changing the purchase_agreement_id (many2one field) but I still need to fill them in the next form upon button click. Here  is my code: 


from odoo import models,api,fields
from odoo.exceptions import ValidationError
class Approval(models.Model):
_inherit = "approval.request"
purchase_agreement_id=fields.Many2one('purchase.requisition', string='Purchase Agreement Id')

@api.onchange('purchase_agreement_id')
def purchase_agreement(self):
lines = []
for rec in self:
for line in rec.purchase_agreement_id.line_ids:
lines.append([0,0,{
'product_id': line.product_id.id,'description':line.product_description_variants,'quantity':line.product_qty
}])
self.product_line_ids=[(6, 0, [])]
self.write({'product_line_ids' : lines})

The above code is only responsible for filling the one2many field in the approval.request model, I have tried so many codes to move the products to the next form but I am stuck. Any help would be appreciated. Thanks

아바타
취소
관련 게시물 답글 화면 활동
0
3월 15
3926
1
5월 25
4346
0
8월 22
2869
1
3월 23
2311
0
12월 22
2935