Divyesh Makwana(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-addons_10_purchase_pricelist-mdi into
lp:openobject-addons.
Requested reviews:
Purnendu Singh (OpenERP) (psi-tinyerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-addons_10_purchase_pricelist-mdi/+merge/125167
Hello Sir,
I have done the following changes:
1. Added a constraint to check Minimum Margin must be lower than Maximum Margin.
2. Added a tooltip for Price-list Rules.
Thanks,
Divyesh
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-addons_10_purchase_pricelist-mdi/+merge/125167
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-addons_10_purchase_pricelist-mdi.
=== modified file 'product/pricelist.py'
--- product/pricelist.py 2012-09-07 13:42:29 +0000
+++ product/pricelist.py 2012-09-25 11:52:26 +0000
@@ -394,6 +394,15 @@
return False
return True
+ def _check_margin(self, cr, uid, ids, context=None):
+ for item in self.browse(cr, uid, ids, context=context):
+ if item.price_min_margin > item.price_max_margin:
+ if item.name:
+ raise osv.except_osv(_('Warning!'), _('Minimum margin must be lower than maximum margin for pricelist rule: \'%s\'(sequence: %s).') % (item.name, item.sequence))
+ else:
+ raise osv.except_osv(_('Warning!'), _('Minimum margin must be lower than maximum margin for pricelist rule having sequence %s.') % (item.sequence))
+ return True
+
_columns = {
'name': fields.char('Rule Name', size=64, help="Explicit rule name for this pricelist line."),
'price_version_id': fields.many2one('product.pricelist.version', 'Price List Version', required=True, select=True, ondelete='cascade'),
@@ -401,13 +410,13 @@
'product_id': fields.many2one('product.product', 'Product', ondelete='cascade', help="Set a product if this rule only apply to one product. Keep empty for all products"),
'categ_id': fields.many2one('product.category', 'Product Category', ondelete='cascade', help="Set a category of product if this rule only apply to products of a category and his children. Keep empty for all products"),
- 'min_quantity': fields.integer('Min. Quantity', required=True, help="The rule only applies if the partner buys/sells more than this quantity."),
+ 'min_quantity': fields.integer('Min. Quantity', required=True, help="The rule only applies if the partner buys/sells equal to or more than this quantity."),
'sequence': fields.integer('Sequence', required=True, help="Gives the order in which the pricelist items will be checked. The evaluation gives highest priority to lowest sequence and stops as soon as a matching item is found."),
'base': fields.selection(_price_field_get, 'Based on', required=True, size=-1, help="The mode for computing the price for this rule."),
'base_pricelist_id': fields.many2one('product.pricelist', 'If Other Pricelist'),
'price_surcharge': fields.float('Price Surcharge',
- digits_compute= dp.get_precision('Product Price')),
+ digits_compute= dp.get_precision('Product Price'), help='Specify the fixed amount to add or substract(if negative) to the amount calculated with the discount.'),
'price_discount': fields.float('Price Discount', digits=(16,4)),
'price_round': fields.float('Price Rounding',
digits_compute= dp.get_precision('Product Price'),
@@ -416,15 +425,16 @@
"To have prices that end in 9.99, set rounding 10, surcharge -0.01" \
),
'price_min_margin': fields.float('Min. Price Margin',
- digits_compute= dp.get_precision('Product Price')),
+ digits_compute= dp.get_precision('Product Price'), help='Specify the minimum amount of margin over the base price.'),
'price_max_margin': fields.float('Max. Price Margin',
- digits_compute= dp.get_precision('Product Price')),
+ digits_compute= dp.get_precision('Product Price'), help='Specify the maximum amount of margin over the base price.'),
'company_id': fields.related('price_version_id','company_id',type='many2one',
readonly=True, relation='res.company', string='Company', store=True)
}
_constraints = [
- (_check_recursion, 'Error ! You cannot assign the Main Pricelist as Other Pricelist in PriceList Item!', ['base_pricelist_id'])
+ (_check_recursion, 'Error ! You cannot assign the Main Pricelist as Other Pricelist in PriceList Item!', ['base_pricelist_id']),
+ (_check_margin, '', ['price_min_margin', 'price_max_margin'])
]
def product_id_change(self, cr, uid, ids, product_id, context=None):
=== modified file 'product/pricelist_view.xml'
--- product/pricelist_view.xml 2012-08-28 07:08:41 +0000
+++ product/pricelist_view.xml 2012-09-25 11:52:26 +0000
@@ -20,7 +20,11 @@
<field name="date_end"/>
<field name="company_id" groups="base.group_multi_company" widget="selection"/>
</group>
- <field name="items_id"/>
+ <notebook>
+ <page string="Rules">
+ <field name="items_id"/>
+ </page>
+ </notebook>
</form>
</field>
</record>
=== modified file 'product/product_pricelist_demo.yml'
--- product/product_pricelist_demo.yml 2012-07-27 11:20:25 +0000
+++ product/product_pricelist_demo.yml 2012-09-25 11:52:26 +0000
@@ -47,7 +47,7 @@
- name: 20% Discount given by my supplier
sequence: 1
price_min_margin: 2
- price_max_margin: -5
+ price_max_margin: 5
product_id: product_product_6
base: -2
-
=== modified file 'product/test/product_pricelist.yml'
--- product/test/product_pricelist.yml 2012-07-27 11:22:28 +0000
+++ product/test/product_pricelist.yml 2012-09-25 11:52:26 +0000
@@ -49,14 +49,14 @@
!python {model: product.product}: |
context.update({'quantity':1, 'date': False, 'partner': ref('base.res_partner_4'), 'pricelist': ref("supplier_pricelist")})
product = self.browse(cr, uid, ref("product_product_6"), context=context)
- assert product.price == 785, "cost price is not correspond."
+ assert product.price == 792, "cost price is not correspond."
-
I check cost price of LCD Monitor if more than 3 Unit.
-
!python {model: product.product}: |
context.update({'quantity':3})
product = self.browse(cr, uid, ref("product_product_6"), context=context)
- assert product.price == 780, "cost price is not correspond."
+ assert product.price == 787, "cost price is not correspond."
-
I print the sale prices report.
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp