Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
5070 Представления

Hi all,
Core Odoo v7 does not support pricelists for invoices. The pricelist is just used on sales orders.

My problem is that we often make direct invoices without using the sales order.

There is a module on apps.odoo.com, named "account_invoice_change_prices".
This module adds a button on the Invoice form that allows us to apply the price for each product line based on the partner pricelist.

This is a solution but it raised another problem. Often users forget to click the "Check Prices" button.

The module uses basically 2 main files.

The account_invoice.py has only one class:

class account_invoice(osv.osv):
    _inherit = 'account.invoice'

    def action_check_prices(self, cr, uid, ids, context=None):
        _sale_orders = self.pool.get('sale.order').search(cr, uid, [('invoice_ids','=',ids[0])])
        
        if len(_sale_orders) == 0:
            _change = False
            for _invoice in self.browse(cr, uid, ids, context):
                _partner = _invoice.partner_id
                _pricelist = _partner.property_product_pricelist and _partner.property_product_pricelist.id or False
                if _pricelist:
                    for _line in _invoice.invoice_line:
                        _price = self.pool.get('product.pricelist').price_get(cr, uid, [_pricelist],
                                 _line.product_id.id, _line.quantity or 1.0, _partner.id, {
                                     'uom': _line.uos_id.id or result.get('product_uos'),
                                     'date': _invoice.date_invoice,
                                     })[_pricelist]
                        if _price and _price != _line.price_unit:
                            _change = True
                            _line.write({'price_unit': _price,
                                         'price_subtotal': False})
            if _change:
                self.button_reset_taxes(cr, uid, ids, context)
        return True

The account_invoice_view.xml only 1 "record":

        <record id="invoice_check_form" model="ir.ui.view">
            <field name="name">account.invoice.check.form</field>
            <field name="model">account.invoice</field>
            <field name="inherit_id" ref="account.invoice_form"/>
            <field name="arch" type="xml">
                <button name="invoice_open" position="before">
                    <button name="action_check_prices" states="draft" string="Check Prices" type="object" groups="base.group_user"/>
                </button>
            </field>
        </record>

Can anyone help me on changing this files/codes in order to automatically add the correct price (based on partner pricelist) on each added product line to the invoice?
This way, everytime a user adds a product to the invoice, the system will add it with the correct price without having to click the "Check Prices" button.

Thank you very much

Regards

Paulo

 

Аватар
Отменить

Hi Paulo, I have partner specific price module for v8. We can customize it the way you want. For any queries: akhil.p.sivan007@gmail.com

Do you have some free development for this problem?

Related Posts Ответы Просмотры Активность
1
июн. 25
719
2
апр. 25
1142
0
янв. 25
1105
1
дек. 24
2544
0
апр. 24
1155