Odoo返回动作或警告

时间:2018-11-03 06:09:17

标签: odoo odoo-10 odoo-9

我正在使用Odoo10,并安装了会员模块和出勤模块。我想扫描条形码,但在继续进行操作之前先让它检查成员资格状态。默认代码检查是否有有效的条形码,因此我尝试将其复制。

此odoo检查条形码的默认代码

@api.model
    def attendance_scan(self, barcode):
        """ Receive a barcode scanned from the Kiosk Mode and change the attendances of corresponding partner.
            Returns either an action or a warning.
        """
        partner = self.search([('barcode', '=', barcode)], limit=1)
        return partner and partner.attendance_action('base_attendance.hr_attendance_action_kiosk_mode') or \
            {'warning': _('No partner corresponding to barcode %(barcode)s') % {'barcode': barcode}}

我想让Membership_state =付费,所以我尝试了

@api.model
    def attendance_scan(self, barcode):
        """ Receive a barcode scanned from the Kiosk Mode and change the attendances of corresponding partner.
            Returns either an action or a warning.
        """
        partner = self.search([('barcode', '=', barcode)], limit=1) and self.partner.membership_state = (self.paid)
        return partner and partner.attendance_action('base_attendance.hr_attendance_action_kiosk_mode') or \
            {'warning': _('No partner corresponding to barcode %(barcode)s') % {'barcode': barcode}}

我得到的错误是

partner = self.search([('barcode', '=', barcode)], limit=1) and self.partner.membership_state = (self.paid)
AttributeError: 'res.partner' object has no attribute 'partner'

membership_state具有多个状态,例如:无,已取消,正在等待,已开具发票和已付款。我只是不做 不知道如何称呼国家

1 个答案:

答案 0 :(得分:0)

我认为您的self本身就是合作伙伴的记录集。如果是,则您无需从partner(self.partner.membership_state)访问self

尝试以下操作:self.membership_state

如果self是一个不同的对象,那么也请发布类定义。