create_from_ui() takes 2 positional arguments

402 views Asked by At

Hello I try port odoo 12 module to odoo 13 and getting such error message. maybe can someone explain how to troubleshoot case of error? maybe there is easy solution? I'm really new to odoo so please give me knowledge's as most possible. In that case may be one more great module developer will grow and develop some free modules :)

There is code:

@api.model
    def create_from_ui(self, orders):
        submitted_references = [o['data']['name'] for o in orders]
        pos_order = self.search([('pos_reference', 'in', submitted_references)])
        existing_orders = pos_order.read(['pos_reference'])
        existing_references = set([o['pos_reference'] for o in existing_orders])
        orders_to_save = [o for o in orders if o['data']['name'] not in existing_references]
        order_ids = []

        order_to_update = [o for o in orders if o['data']['name'] in existing_references]
        # Keep only new orders
        for tmp_order in orders_to_save:
            to_invoice = tmp_order['to_invoice']
            order = tmp_order['data']
            if to_invoice:
                self._match_payment_to_invoice(order)
            pos_order = self._process_order(order)
            order_ids.append(pos_order.id)

            try:
                pos_order.action_pos_order_paid()
            except psycopg2.OperationalError:
                # do not hide transactional errors, the order(s) won't be saved!
                raise
            except Exception as e:
                _logger.error('Could not fully process the POS Order: %s', tools.ustr(e))

            if to_invoice:
                pos_order.action_pos_order_invoice()
                pos_order.invoice_id.sudo().action_invoice_open()
                pos_order.account_move = pos_order.invoice_id.move_id

        # Update draft orders
        for tmp_order in order_to_update:
            for order in pos_order:
                if order.pos_reference == tmp_order['data']['name']:
                    pos_line_ids = self.env['pos.order.line'].search([('order_id', '=', order.id)])
                    if pos_line_ids:
                        pos_cids = []
                        new_cids = []
                        for line_id in pos_line_ids:
                            pos_cids.append(line_id.pos_cid)
                            for line in tmp_order['data']['lines']:
                                if line_id.pos_cid == line[2].get('pos_cid'):
                                    new_cids.append(line[2].get('pos_cid'))
                                    order.write({'lines': [(1, line_id.id, line[2])]})

                        for line in tmp_order['data']['lines']:
                            if line[2].get('pos_cid') not in pos_cids:
                                order.write({'lines': [(0, 0, line[2])]})
                                pos_cids.append(line[2].get('pos_cid'))
                                new_cids.append(line[2].get('pos_cid'))

                        newList = []
                        for item in pos_cids:
                            if item not in new_cids:
                                newList.append(item)

                        order_line_ids = self.env['pos.order.line'].search([('pos_cid', 'in', newList)])
                        if order_line_ids:
                            for each_line in order_line_ids:
                                each_line.unlink()

                    to_invoice = tmp_order['to_invoice']
                    order = tmp_order['data']
                    if to_invoice:
                        self._match_payment_to_invoice(order)
                    pos_order = self._process_order(order)
                    order_ids.append(pos_order.id)

                    try:
                        pos_order.action_pos_order_paid()
                    except psycopg2.OperationalError:
                        # do not hide transactional errors, the order(s) won't be saved!
                        raise
                    except Exception as e:
                        _logger.error('Could not fully process the POS Order: %s', tools.ustr(e))

                    if to_invoice:
                        pos_order.action_pos_order_invoice()
                        pos_order.invoice_id.sudo().action_invoice_open()
                        pos_order.account_move = pos_order.invoice_id.move_id
        self.broadcast_order_data(True)

        return order_ids

And there is error what i am getting:

  File "/usr/lib/python3/dist-packages/odoo/api.py", line 356, in _call_kw_model
    result = method(recs, *args, **kwargs)
TypeError: create_from_ui() takes 2 positional arguments but 3 were given
1

There are 1 answers

3
Dipen Shah On

Klasik

As the Error Log suggests that the method which you adapts changes in odoo13 with terms of arguments.

you can check here the new signature method for odoo13.

Thanks