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

right now i am using a module from github, that creates a page in product that lists all the "prices" from product.pricelist of the product. What i want, is to take the "price_list" of the product, and substract the discount in each line.


import math

import re

import logging

import openerp.addons.decimal_precision as dp

#from _common import rounding

from openerp import tools

from openerp.osv import osv, fields

from openerp.tools.translate import _

_logger = logging.getLogger(__name__) # Need for message in console.

class product_template(osv.osv):

_name = 'product.template'

_inherit = 'product.template'

_columns = {

# For display price in product.

'prices_ids': fields.one2many('product.pricelist.item', 'product_id', 'Supplier'),

'price_bas': fields.Char('Display Name', related='price_list.price.bas',store=True),

}

product_template()

class product_pricelist_item(osv.osv):

_name = 'product.pricelist.item'

_inherit = 'product.pricelist.item'

_columns = {

}

product_pricelist_item()


Bold, added by me, making some mistakes. I couldnt get to the point of showing the "price_list" = standard price of the product, into the new price page, yet.


This is the xml.


<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data>

<record id="price_list_tab_view" model="ir.ui.view">

<field name="name">product.template.product.form</field>

<field name="model">product.template</field>

<field name="type">form</field>

<field name="inherit_id" ref="product.product_template_form_view" />

<field name="arch" type="xml">

<xpath expr="/form/sheet/notebook" position="inside" version="7.0">

<page string="Prices" >

<group >

<field name="price.bas"/>

</group>

<group colspan="2" col="2">

<field name="prices_ids" nolabel="1" widget="one2many_list" >

<tree string="Price List">

<field name="price_version_id"/>

<field name="min_quantity"/>

<field name="price_surcharge" string="Descuento"/>

</tree>

</field>

</group>

</page>

</xpath>

</field>

</record>

<!-- it for posible add price from product -->

<record id="price_versionid_form_view" model="ir.ui.view">

<field name="name">product.pricelist.item.form</field>

<field name="model">product.pricelist.item</field>

<field name="type">form</field>

<field name="inherit_id" ref="product.product_pricelist_item_form_view" />

<field name="arch" type="xml">

<xpath expr="//field[@name='product_id']" position='before'>

<group col="4" string="Price version">

<field name="price_version_id"/>

</group>

</xpath>

</field>

</record>

</data>

</openerp>

Avatar
Discard
Author Best Answer

Update:


I finally managed to show the "list_price" as a column with the "price_surcharge" also, now i want to add a third column, with that subtract "list_price" - "price_surcharge" = third_column.

This is mas code so far:

# -*- coding: utf-8 -*-

#from osv import fields, osv

import math

import re

import logging

import openerp.addons.decimal_precision as dp

#from _common import rounding

from openerp import tools, models, fields, api

from openerp.osv import osv, fields

from openerp.tools.translate import _

_logger = logging.getLogger(__name__) # Need for message in console.

class product_pricelist_item(osv.osv):

_inherit = 'product.pricelist.item'

_columns = {

'list_price': fields.related('product_id', 'list_price', type='char', string='List Price', relation="product.template", store=False, readonly=True ),

}

product_pricelist_item()

class product_template(osv.osv):

_name = 'product.template'

_inherit = 'product.template'

_columns = {

# For display price in product.

'prices_ids': fields.one2many('product.pricelist.item', 'product_id', 'Supplier')

}

product_template()

Avatar
Discard
Related Posts Replies Views Activity
2
Apr 23
4988
3
Apr 17
9868
1
May 16
7990
0
May 16
2252
1
Jan 24
1063