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

HI,I am trying to customize my point of sale in the module and what I should do is obtain the values: customer name, address, product name, quantity, price, subtotal, tax, total order at the time of pressing the validate button in a directory or list someone could guide me on how to do it in version 12.0

I leave the code of what I want to do.

    @api.multi
    def action_pos_order_invoice(self):
        Invoice = self.env['account.invoice']
        Partner = self.env['res.partner']
        for order in self:
            # Force company for all SUPERUSER_ID action
            local_context = dict(self.env.context, force_company=order.company_id.id, company_id=order.company_id.id)
            if order.invoice_id:
                Invoice += order.invoice_id
                continue

            if not order.partner_id:
                raise UserError(_('Please provide a partner for the sale.'))

            invoice = Invoice.new(order._prepare_invoice())
            invoice._onchange_partner_id()
            invoice.fiscal_position_id = order.fiscal_position_id

            inv = invoice._convert_to_write({name: invoice[name] for name in invoice._cache})
            new_invoice = Invoice.with_context(local_context).sudo().create(inv)
            
---------Aca estoy intentando obtener los datos pero no logro los resultados correctos----------------------
            Listado = dict(order._prepare_invoice())
            val = Listado['partner_id']
            id_needed = Partner.search([('partner_id', '=', val)]).id
            new = wt.browse(id_needed)
            list = [new.name]
---------------------------------------------------------------------------------------------------------------------------------------------
            message = _("This invoice has been created from the point of sale session: <a href=# data-oe-model=pos.order data-oe-id=%d>%s</a>") % (order.id, order.name)
            new_invoice.message_post(body=message)
            order.write({'invoice_id': new_invoice.id, 'state': 'invoiced'})
            Invoice += new_invoice

            for line in order.lines:
                self.with_context(local_context)._action_create_invoice_line(line, new_invoice.id)

            new_invoice.with_context(local_context).sudo().compute_taxes()
            order.sudo().write({'state': 'invoiced'})

        if not Invoice:
            return {}

        return {
            'name': _('Customer Invoice'),
            'view_type': 'form',
            'view_mode': 'form',
            'view_id': self.env.ref('account.invoice_form').id,
            'res_model': 'account.invoice',
            'context': "{'type':'out_invoice'}",
            'type': 'ir.actions.act_window',
            'nodestroy': True,
            'target': 'current',
            'res_id': Invoice and Invoice.ids[0] or False,
        }


Avatar
Discard
Best Answer

Hello,

you can try search_read method or read method of odoo, which give you result in list. you can take invoice, pos order and partner object search_read or read method. and combine them. as you need data.

Avatar
Discard
Related Posts Replies Views Activity
1
May 21
3616
0
Dec 24
17
2
Dec 24
88
3
Nov 24
2231
0
Sep 24
122