Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

How to add amount of One2many table?

By
Juan Carlos
on 12/19/14, 5:00 PM 594 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>

0

deep

--deep--
1617
| 5 4 7
Bengaluru, India
--deep--

Techno-Functional Associate with 6+ years of experience in Odoo (formerly known as OpenERP).

deep
On 12/22/14, 1:18 AM

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 12/19/14, 5:00 PM
Seen: 594 times
Last updated: 3/16/15, 8:10 AM