This question has been flagged
1 Reply
3517 Views

Help, please. This is my code.

my.py

class Facturacion(models.Model):
    _name = 'openacademy.factura'

    numeroFactura = fields.Char(string="No. Factura")
    serieFactura = fields.Char(string="Serie")
    fechaFactura = fields.Date(string="Fecha")
    cantidadFactura = fields.Float('Cantidad')
    #keys
    empresa_ids = fields.Many2one('openacademy.empresa', 'Empresa')
    producto_box = fields.One2many('openacademy.detalle', 'name')
    pago_ids = fields.Many2one('openacademy.pago', 'Tipo de Pago')
    partner_ids = fields.Many2one('res.partner', 'Cliente')
    totales = fields.Float(string="Totales", readonly=True)

class DetalleFactura(models.Model):
    _name = "openacademy.detalle"

    @api.onchange('producto_id')
    def _onchange_producto_id(self):
        if self.producto_id:
            self.precio = 100.00

    name = fields.Char(string="Titulo")
    producto_id = fields.Many2one('product.product', 'Producto')
    precio = fields.Float(string="Precio")

my.xml

<notebook>
                            <page string="Compras">
                                    <group string="Compras">
                                        <field name="producto_box" nolabel="1">
                                            <tree editable="bottom">
                                                <field name="producto_id"/>
                                                <field name="precio" />
                                            </tree>
                                        </field>
                                    </group >
                                    <br />
                                    <group>
                                        <group class="oe_subtotal_footer">
                                            <field name="totales" class="oe_subtotal_footer_separator"/>
                                        </group>
                                    </group>
                            </page>
                        </notebook>

Avatar
Discard
Best Answer

Refer Invoice object or Sale Order object etc, to achieve your requirement

Avatar
Discard