0

我对此很陌生。我正在创建一个酒店模块,我有一个名为 Guest number 的字段和一个名为 guest line 的 One2many 字段。因此,如果我在提交的客人编号中输入 5 并在 many2one 中添加 4 个客人详细信息,我应该会收到警告。这应该检查我何时单击我创建的签入按钮。如果一切正确,则状态应移至检查状态。但我收到错误:

TypeError: button_check_in() missing 2 required positional arguments:

xml

     <button name="button_check_in" string="Check-in" states="draft"  class="oe_highlight"
                            type="object"/>
     <notebook>
                            <page string="Guest Information">
                                <field name="guest_lines">
                                 <tree editable="bottom">
                                     <field name="guest_name"/>
                                     <field name="guest_age"/>
                                     <field name="guest_gender"/>
                                     <field name="guest_id" invisible="1"/>

                                 </tree>

                                </field>

                            </page>

                        </notebook>

型号

    class HotelAccommodation(models.Model):
        _name = 'accommodation.room'
        _inherit = ['mail.thread', 'mail.activity.mixin']
        _description = 'Reception'
        _rec_name = 'name_sequence'
     
        guest_lines = fields.One2many('accommodation.guest', 'guest_id', string="Guest lines")
        count = fields.Integer()
        guest_number = fields.Integer('No of Guest', required=True)




    class HotelGuestInformation(models.Model):
        _name = 'accommodation.guest'
        _description = 'Accommodation guest information'

        guest_name = fields.Char(' Name', required=True)
        guest_age = fields.Integer('Age')
        guest_id = fields.Many2one('accommodation.room', string='Guest ID')


        guest_gender = fields.Selection([
            ('male','Male'),
            ('female','female'),
        ], required=True, default='other')

功能

    def button_check_in(self):
        for rec in self:
            rec.state = 'check-in'
        count = len(self.guest_id)
        if guest_number != count:
                 raise Warning(_("Please enter all the guest dedtails))

在此处输入图像描述

4

0 回答 0