Skip to Content
Menu
This question has been flagged
1 Reply
2406 Views

from odoo import models, fields, api class Approver_PO(models.Model):

                _inherit = 'purchase.order'

    def get_user_id(self):

        return self.env.uid

    @api.multi

    def button_approve(self, force=False):

        self.write({'state': 'purchase'})

        self._create_picking()

        approver_id = fields.Many2one('res.users','Approved By', default=_get_user_id)

        if self.company_id.po_lock == 'lock':

            self.write({'state': 'done'})

        return {}

Avatar
Discard
Best Answer

Hi Gelo Panelo,

Please try this code.

from odoo import models, fields, api

class Approver_PO(models.Model):
_inherit = 'purchase.order'

approver_id = fields.Many2one('res.users','Approved By')

@api.multi
def button_approve(self, force=False):
result = super(Approver_PO, self).button_approve(force=force)
for po in self:
po.write({'approver_id': self.env.uid})
return result


Hope it will help you.

Avatar
Discard
Related Posts Replies Views Activity
1
Aug 24
421
2
Nov 24
751
3
Oct 23
13195
2
Feb 23
1229
1
Dec 22
1371