Ujjvala Collins (OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/trunk-v62_purchase-tpa into lp:openobject-addons.
Requested reviews: OpenERP Core Team (openerp) For more details, see: https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-v62_purchase-tpa/+merge/97211 [ADD]: ------ * Added new configuration wizard for Purchase application. -- https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-v62_purchase-tpa/+merge/97211 Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-v62_purchase-tpa.
=== modified file 'product/__init__.py' --- product/__init__.py 2011-01-14 00:11:01 +0000 +++ product/__init__.py 2012-03-13 12:56:53 +0000 @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- ############################################################################## -# +# # OpenERP, Open Source Management Solution # Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). # @@ -15,7 +15,7 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# along with this program. If not, see <http://www.gnu.org/licenses/>. # ############################################################################## import product @@ -23,5 +23,6 @@ import report import partner import wizard +import res_config # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: === modified file 'product/partner_view.xml' --- product/partner_view.xml 2011-01-14 00:11:01 +0000 +++ product/partner_view.xml 2012-03-13 12:56:53 +0000 @@ -9,7 +9,7 @@ <field name="arch" type="xml"> <page string="Sales & Purchases" position="inside"> <newline/> - <group col="2" colspan="2" groups="base.group_extended"> + <group col="2" colspan="2" groups="base.group_sale_pricelist_per_customer"> <separator string="Sales Properties" colspan="2"/> <field name="property_product_pricelist"/> </group> === modified file 'product/pricelist_view.xml' --- product/pricelist_view.xml 2011-12-19 16:54:40 +0000 +++ product/pricelist_view.xml 2012-03-13 12:56:53 +0000 @@ -4,7 +4,8 @@ <menuitem id="base.menu_sale_config_sales" name="Sales" parent="base.menu_base_config" sequence="0" groups="base.group_extended"/> - <menuitem groups="base.group_extended" id="menu_product_pricelist_main" name="Pricelists" parent="base.menu_base_config" sequence="50"/> + <menuitem id="menu_product_pricelist_main" name="Pricelists" + parent="base.menu_base_config" groups="base.group_sale_pricelist_per_customer" sequence="50"/> <record id="product_pricelist_version_form_view" model="ir.ui.view"> <field name="name">product.pricelist.version.form</field> @@ -195,7 +196,7 @@ </form> </field> </record> - + <record id="product_price_type_action" model="ir.actions.act_window"> <field name="name">Price Types</field> <field name="type">ir.actions.act_window</field> === modified file 'product/product_view.xml' --- product/product_view.xml 2012-02-09 17:00:46 +0000 +++ product/product_view.xml 2012-03-13 12:56:53 +0000 @@ -20,7 +20,7 @@ <field name="categ_id" widget="selection" operator="child_of" groups="base.group_extended"/> <newline/> <group expand="0" string="Context..." groups="base.group_extended"> - <field name="pricelist_id" widget="selection" context="{'pricelist': self}" /> + <field name="pricelist_id" widget="selection" context="{'pricelist': self}" groups="base.group_sale_pricelist_per_customer"/> <separator orientation="vertical" groups="base.group_multi_company" /> <field name="company_id" widget="selection" groups="base.group_multi_company" /> </group> @@ -50,7 +50,7 @@ <field name="name"/> <field name="categ_id" invisible="1"/> <field name="variants" groups="product.group_product_variant"/> - <field name="uom_id" string="UoM"/> + <field name="uom_id" string="UoM" groups="base.group_sale_uom_per_product"/> <field name="type"/> <field name="qty_available"/> <field name="virtual_available"/> @@ -87,7 +87,7 @@ </group> <group colspan="1" col="1"> <field name="product_image" widget='image' nolabel="1"/> - </group> + </group> </group> <notebook colspan="4"> @@ -125,11 +125,11 @@ <group colspan="2" col="2" name="uom"> <separator string="Unit of Measure" colspan="2"/> - <field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)"/> + <field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)" groups="base.group_sale_uom_per_product"/> <field name="uom_po_id" groups="base.group_extended"/> </group> - <group colspan="2" col="2" name="uos" groups="product.group_uos"> + <group colspan="2" col="2" name="uos" groups="base.group_sale_uom_per_product"> <separator string="Second UoM" colspan="2"/> <field name="uos_id"/> <field name="uos_coeff"/> @@ -257,24 +257,24 @@ <field name="view_mode">tree,form,kanban</field> <field name="view_type">form</field> <field name="context">{"search_default_filter_to_sell":1}</field> - <field name="view_id" ref="product_product_tree_view"/> - <field name="search_view_id" ref="product_search_form_view"/> + <field name="view_id" ref="product_product_tree_view"/> + <field name="search_view_id" ref="product_search_form_view"/> <field name="help">You must define a Product for everything you buy or sell. Products can be raw materials, stockable products, consumables or services. The Product form contains detailed information about your products related to procurement logistics, sales price, product category, suppliers and so on.</field> </record> - + <record id="open_view_product_tree1" model="ir.actions.act_window.view"> <field name="sequence" eval="1"/> <field name="view_mode">tree</field> <field name="view_id" ref="product_product_tree_view"/> <field name="act_window_id" ref="product_normal_action_sell"/> </record> - + <record id="open_view_product_form1" model="ir.actions.act_window.view"> <field name="sequence" eval="2"/> <field name="view_mode">form</field> <field name="view_id" ref="product_normal_form_view"/> <field name="act_window_id" ref="product_normal_action_sell"/> - </record> + </record> <menuitem id="base.menu_product" name="Products" parent="base.menu_base_partner" sequence="9"/> <menuitem action="product.product_normal_action_sell" id="product.menu_products" parent="base.menu_product" sequence="1"/> @@ -440,7 +440,7 @@ <field name="view_id" ref="product_uom_tree_view"/> <field name="help">Create and manage the units of measure you want to be used in your system. You can define a conversion rate between several Units of Measure within the same category.</field> </record> - <menuitem id="next_id_16" name="Units of Measure" parent="prod_config_main" sequence="65"/> + <menuitem id="next_id_16" name="Units of Measure" parent="prod_config_main" sequence="65" groups="base.group_sale_uom_per_product"/> <menuitem action="product_uom_form_action" id="menu_product_uom_form_action" parent="next_id_16"/> <record id="product_uom_categ_form_view" model="ir.ui.view"> @@ -552,7 +552,7 @@ <field name="product_uom"/> <field name="delay"/> <field name="company_id" groups="base.group_multi_company" widget="selection"/> - <field colspan="4" groups="base.group_extended" name="pricelist_ids" nolabel="1" widget="one2many_list"> + <field colspan="4" groups="base.group_sale_pricelist_per_customer" name="pricelist_ids" nolabel="1" widget="one2many_list"> <tree editable="bottom" string="Pricelist"> <field name="min_quantity"/> <field name="price"/> @@ -674,11 +674,11 @@ <group colspan="2" col="2" name="uom"> <separator string="UOM" colspan="2"/> - <field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)"/> + <field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)" groups="base.group_sale_uom_per_product"/> <field name="uom_po_id" groups="base.group_extended"/> </group> - <group colspan="2" col="2" name="uos" groups="product.group_uos"> + <group colspan="2" col="2" name="uos" groups="base.group_sale_uom_per_product"> <separator string="Second UoM" colspan="2"/> <field name="uos_id"/> <field name="uos_coeff"/> === added file 'product/res_config.py' --- product/res_config.py 1970-01-01 00:00:00 +0000 +++ product/res_config.py 2012-03-13 12:56:53 +0000 @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from osv import fields, osv + +class product_groups_configuration(osv.osv_memory): + _inherit = 'res.config.settings' + + _columns = { + 'group_sale_pricelist_per_customer':fields.boolean("Pricelist per Customer", + group='base.group_user', implied_group='base.group_sale_pricelist_per_customer', + help="""Allows to manage different prices based on rules per category of customers. + Example: 10% for retailers, promotion of 5 EUR on this product, etc. + It assigns the "Pricelist" group to all employees."""), + 'group_sale_uom_per_product':fields.boolean("UOM per product", + group='base.group_user', implied_group='base.group_sale_uom_per_product', + help=""" + Allows you to select and maintain different unit of measures per product. + It assigns the "UOM per product" group to all employees. + """), + 'group_purchase_pricelist_per_supplier':fields.boolean("Pricelist per Supplier", group='base.group_user', xml_id='base.group_purchase_pricelist_per_supplier', + help="""Allows to manage different prices based on rules per category of Supplier. + Example: 10% for retailers, promotion of 5 EUR on this product, etc. + It assigns the "Pricelist" group to all employees."""), + 'group_stock_packaging':fields.boolean("Manage packaging by products", group='base.group_user', implied_group='base.group_stock_packaging', + help=""" Allows you to create and manage your packaging dimensions and types you want to be maintained in your system. + It assigns the "Packaging" group to employee."""), +} + +product_groups_configuration() \ No newline at end of file === modified file 'product/security/product_security.xml' --- product/security/product_security.xml 2011-12-19 16:54:40 +0000 +++ product/security/product_security.xml 2012-03-13 12:56:53 +0000 @@ -19,6 +19,33 @@ <field name="category_id" ref="base.module_category_usability"/> </record> + <record id="base.group_sale_pricelist_per_customer" model="res.groups"> + <field name="name">Sales Pricelists</field> + <field name="category_id" ref="base.module_category_hidden"/> + </record> + + <record id="base.group_purchase_pricelist_per_supplier" model="res.groups"> + <field name="name">Purchase Pricelists</field> + <field name="category_id" ref="base.module_category_hidden"/> + </record> + + <record id="base.group_sale_uom_per_product" model="res.groups"> + <field name="name">Product UOM</field> + <field name="category_id" ref="base.module_category_hidden"/> + </record> + + <record id="base.group_stock_packaging" model="res.groups"> + <field name="name">Packaging</field> + <field name="category_id" ref="base.module_category_hidden"/> + </record> + + <record id="base.group_user" model="res.groups"> + <field name="implied_ids" eval="[(6,0,[ref('base.group_sale_pricelist_per_customer'), + ref('base.group_sale_uom_per_product'), + ref('base.group_purchase_pricelist_per_supplier'), + ref('base.group_stock_packaging')])]"/> + </record> + <record model="ir.rule" id="product_pricelist_comp_rule"> <field name="name">product pricelist company rule</field> <field name="model_id" ref="model_product_pricelist"/> === modified file 'product/wizard/product_price_view.xml' --- product/wizard/product_price_view.xml 2011-01-14 00:11:01 +0000 +++ product/wizard/product_price_view.xml 2012-03-13 12:56:53 +0000 @@ -31,6 +31,7 @@ name="Price List" res_model="product.price_list" src_model="product.product" + groups="base.group_sale_pricelist_per_customer" view_mode="form" target="new" view_type="form" /> </data> === modified file 'purchase/__init__.py' --- purchase/__init__.py 2011-10-06 16:34:25 +0000 +++ purchase/__init__.py 2012-03-13 12:56:53 +0000 @@ -27,6 +27,7 @@ import stock import company import edi +import res_config # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: === modified file 'purchase/__openerp__.py' --- purchase/__openerp__.py 2012-02-13 15:27:55 +0000 +++ purchase/__openerp__.py 2012-03-13 12:56:53 +0000 @@ -60,6 +60,7 @@ 'report/purchase_report_view.xml', 'board_purchase_view.xml', 'edi/purchase_order_action_data.xml', + 'res_config_view.xml', ], 'test': [ 'test/process/cancel_order.yml', === modified file 'purchase/partner_view.xml' --- purchase/partner_view.xml 2011-01-14 00:11:01 +0000 +++ purchase/partner_view.xml 2012-03-13 12:56:53 +0000 @@ -9,7 +9,7 @@ <field name="priority">36</field> <field name="arch" type="xml"> <page string="Sales & Purchases" position="inside"> - <group colspan="2" col="2" groups="base.group_extended"> + <group colspan="2" col="2" groups="base.group_purchase_pricelist_per_supplier"> <separator string="Purchase Properties" colspan="2"/> <field name="property_product_pricelist_purchase" /> </group> === modified file 'purchase/purchase.py' --- purchase/purchase.py 2012-02-28 14:08:16 +0000 +++ purchase/purchase.py 2012-03-13 12:56:53 +0000 @@ -207,6 +207,7 @@ 'product_id': fields.related('order_line','product_id', type='many2one', relation='product.product', string='Product'), 'create_uid': fields.many2one('res.users', 'Responsible'), 'company_id': fields.many2one('res.company','Company',required=True,select=1), + 'tax_id': fields.many2one('account.tax', 'Tax'), } _defaults = { 'date_order': fields.date.context_today, @@ -295,7 +296,7 @@ return True def _prepare_inv_line(self, cr, uid, account_id, order_line, context=None): - """Collects require data from purchase order line that is used to create invoice line + """Collects require data from purchase order line that is used to create invoice line for that purchase order line :param account_id: Expense account of the product of PO line if any. :param browse_record order_line: Purchase order line browse record @@ -379,7 +380,7 @@ 'address_invoice_id': order.partner_address_id.id, 'address_contact_id': order.partner_address_id.id, 'journal_id': len(journal_ids) and journal_ids[0] or False, - 'invoice_line': [(6, 0, inv_lines)], + 'invoice_line': [(6, 0, inv_lines)], 'origin': order.name, 'fiscal_position': order.fiscal_position.id or order.partner_id.property_account_position.id, 'payment_term': order.partner_id.property_payment_term and order.partner_id.property_payment_term.id or False, @@ -420,7 +421,7 @@ if inv: wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_cancel', cr) self.write(cr,uid,ids,{'state':'cancel'}) - + for (id, name) in self.name_get(cr, uid, ids): wf_service.trg_validate(uid, 'purchase.order', id, 'purchase_cancel', cr) message = _("Purchase order '%s' is cancelled.") % name @@ -439,7 +440,7 @@ 'company_id': order.company_id.id, 'move_lines' : [], } - + def _prepare_order_line_move(self, cr, uid, order, order_line, picking_id, context=None): return { 'name': order.name + ': ' + (order_line.name or ''), @@ -480,7 +481,7 @@ will be added. A new picking will be created if omitted. :return: list of IDs of pickings used/created for the given order lines (usually just one) """ - if not picking_id: + if not picking_id: picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, context=context)) todo_moves = [] stock_move = self.pool.get('stock.move') @@ -732,7 +733,7 @@ """ if context is None: context = {} - + res = {'value': {'price_unit': price_unit or 0.0, 'name': name or '', 'notes': notes or '', 'product_uom' : uom_id or False}} if not product_id: return res @@ -756,7 +757,7 @@ context_partner = {'lang': lang, 'partner_id': partner_id} product = product_product.browse(cr, uid, product_id, context=context_partner) res['value'].update({'name': product.name, 'notes': notes or product.description_purchase}) - + # - set a domain on product_uom res['domain'] = {'product_uom': [('category_id','=',product.uom_id.category_id.id)]} @@ -764,7 +765,7 @@ product_uom_po_id = product.uom_po_id.id if not uom_id: uom_id = product_uom_po_id - + if product.uom_id.category_id.id != product_uom.browse(cr, uid, uom_id, context=context).category_id.id: res['warning'] = {'title': _('Warning'), 'message': _('Selected UOM does not belong to the same category as the product UOM')} uom_id = product_uom_po_id @@ -794,7 +795,7 @@ # - determine price_unit and taxes_id price = product_pricelist.price_get(cr, uid, [pricelist_id], product.id, qty or 1.0, partner_id, {'uom': uom_id, 'date': date_order})[pricelist_id] - + taxes = account_tax.browse(cr, uid, map(lambda x: x.id, product.supplier_taxes_id)) fpos = fiscal_position_id and account_fiscal_position.browse(cr, uid, fiscal_position_id, context=context) or False taxes_ids = account_fiscal_position.map_tax(cr, uid, fpos, taxes) === modified file 'purchase/purchase_view.xml' --- purchase/purchase_view.xml 2012-02-07 13:17:19 +0000 +++ purchase/purchase_view.xml 2012-03-13 12:56:53 +0000 @@ -14,7 +14,7 @@ <menuitem id="menu_purchase_config_pricelist" name="Pricelists" - parent="menu_purchase_config_purchase" sequence="50" groups="base.group_extended"/> + parent="menu_purchase_config_purchase" sequence="50" groups="base.group_purchase_pricelist_per_supplier"/> <menuitem action="product.product_pricelist_action" id="menu_product_pricelist_action_purhase" @@ -39,7 +39,7 @@ <menuitem id="menu_purchase_unit_measure_purchase" name="Units of Measure" - parent="purchase.menu_product_in_config_purchase" sequence="20"/> + parent="purchase.menu_product_in_config_purchase" sequence="20" groups="base.group_sale_uom_per_product"/> <menuitem action="product.product_uom_categ_form_action" id="menu_purchase_uom_categ_form_action" @@ -174,7 +174,7 @@ <page string="Purchase Order"> <field name="partner_id" on_change="onchange_partner_id(partner_id)" context="{'search_default_supplier':1,'default_supplier':1,'default_customer':0}" options='{"quick_create": false}'/> <field name="partner_address_id" options='{"quick_create": false}'/> - <field domain="[('type','=','purchase')]" name="pricelist_id" groups="base.group_extended"/> + <field domain="[('type','=','purchase')]" name="pricelist_id" groups="base.group_purchase_pricelist_per_supplier"/> <field name="origin" groups="base.group_extended"/> <newline/> <field colspan="4" name="order_line" nolabel="1" mode="tree,form"> @@ -182,15 +182,16 @@ <field name="date_planned"/> <field name="name"/> <field name="product_qty"/> - <field name="product_uom"/> + <field name="product_uom" groups="base.group_sale_uom_per_product"/> <field name="price_unit"/> <field name="price_subtotal"/> </tree> <!-- default form view --> </field> <group col="7" colspan="4"> - <field name="amount_untaxed" sum="Untaxed amount"/> - <field name="amount_tax"/> + <field name="amount_untaxed" sum="Untaxed amount" groups="base.group_purchase_taxes_on_order_line,base.group_purchase_taxes_global_on_order"/> + <field name="amount_tax" groups="base.group_purchase_taxes_on_order_line,base.group_purchase_taxes_global_on_order"/> + <field name="tax_id" groups="base.group_sale_taxes_global_on_order"/> <field name="amount_total" sum="Total amount"/> <button name="button_dummy" states="draft" string="Compute" type="object" icon="gtk-execute"/> </group> @@ -304,7 +305,7 @@ </search> </field> </record> - + <record id="purchase_order_tree" model="ir.ui.view"> <field name="name">purchase.order.tree</field> <field name="model">purchase.order</field> @@ -361,13 +362,13 @@ <page string="Order Line"> <field name="product_id" colspan="4" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)" required="1"/> <field name="product_qty" on_change="onchange_product_id(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id,parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)"/> - <field name="product_uom" on_change="onchange_product_uom(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)"/> + <field name="product_uom" groups="base.group_sale_uom_per_product" on_change="onchange_product_uom(parent.pricelist_id,product_id,product_qty,product_uom,parent.partner_id, parent.date_order,parent.fiscal_position,date_planned,name,price_unit,notes,context)"/> <field colspan="4" name="name"/> <field name="date_planned" widget="date"/> <field name="price_unit"/> <field name="company_id" groups="base.group_multi_company" widget="selection"/> <field name="account_analytic_id" colspan="4" groups="analytic.group_analytic_accounting" domain="[('parent_id','!=',False)]" /> - <group colspan="4" col="4" groups="base.group_extended"> + <group colspan="4" col="4" groups="base.group_purchase_taxes_on_order_line"> <separator colspan="4" string="Taxes"/> <field colspan="4" nolabel="1" name="taxes_id" domain="[('parent_id','=',False),('type_tax_use','!=','sale')]"/> @@ -403,7 +404,7 @@ <field name="product_id"/> <field name="price_unit"/> <field name="product_qty"/> - <field name="product_uom"/> + <field name="product_uom" groups="base.group_sale_uom_per_product"/> <field name="price_subtotal"/> <field name="date_planned" widget="date" width="135"/> <field name="state" invisible="1"/> @@ -424,7 +425,7 @@ <field name="order_id"/> <field name="product_id" readonly="1" /> <field name="product_qty" readonly="1" /> - <field name="product_uom" readonly="1"/> + <field name="product_uom" readonly="1" groups="base.group_sale_uom_per_product"/> <field colspan="4" name="name"/> <field name="date_planned" widget="date" readonly="1"/> <field name="price_unit"/> === added file 'purchase/res_config.py' --- purchase/res_config.py 1970-01-01 00:00:00 +0000 +++ purchase/res_config.py 2012-03-13 12:56:53 +0000 @@ -0,0 +1,120 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Management Solution +# Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +############################################################################## + +from osv import fields, osv +import pooler +from tools.translate import _ + +class purchase_configuration(osv.osv_memory): + _name = 'purchase.configuration' + _inherit = 'res.config.settings' + + _columns = { + 'default_invoice_method' : fields.selection( + [('manual', 'Based on Purchase Order Lines'), + ('picking', 'Based on Receptions'), + ('order', 'Pre-Generate Draft Invoices based on Purchase Orders'), + ], 'Invoicing Control Method', required=True, default_model='purchase.order' , help="You can set Invoicing Control Method."), + 'module_purchase_analytic_plans': fields.boolean('Purchase analytic plan', + help =""" + Allows the user to maintain several analysis plans. These let you split + a line on a supplier purchase order into several accounts and analytic plans. + It installs the purchase_analytic_plans module. + """), + 'module_warning': fields.boolean("Alerts by products or customers", + help="""To trigger warnings in OpenERP objects. + Warning messages can be displayed for objects like sale order, purchase order, picking and invoice. The message is triggered by the form's onchange event. + It installs the warning module."""), + 'module_product_manufacturer': fields.boolean("Define a manufacturer of products", + help="""This allows you to define the following for a product: + * Manufacturer + * Manufacturer Product Name + * Manufacturer Product Code + * Product Attributes. + It installs the product_manufacturer module."""), + 'module_purchase_double_validation': fields.boolean("Configure limit amount", + help="""This allows you double-validation for purchases exceeding minimum amount. + It installs the purchase_double_validation module."""), + 'module_purchase_requisition' : fields.boolean("Track the best price with Purchase Requisition", + help="""When a purchase order is created, you now have the opportunity to save the related requisition. + This new object will regroup and will allow you to easily keep track and order all your purchase orders. + It Installs purchase_requisition module."""), + 'tax_policy': fields.selection([ + ('no_tax', 'No Tax'), + ('global_on_order', 'Global On Order'), + ('on_order_line', 'On Order Lines'), + ], 'Taxes', required=True, + help=""" + If you want to apply global tax on sale order then select 'Global On Order' it will add 'Global On Order' group to employees. + If you want to apply different taxes for sale order lines then select 'On Order Lines' it will add 'On Order Lines' group to employees. + """), + 'group_purchase_taxes_global_on_order':fields.boolean("Global on order", group='base.group_user', implied_group='base.group_purchase_taxes_global_on_order'), + 'group_purchase_taxes_on_order_line':fields.boolean("On order line", group='base.group_user', implied_group='base.group_purchase_taxes_on_order_line'), + } + + def default_get(self, cr, uid, fields, context=None): + data_obj = self.pool.get('ir.model.data') + res = super(purchase_configuration, self).default_get(cr, uid, fields, context) + if res.get('group_purchase_taxes_global_on_order'): + res.update({'tax_policy': 'global_on_order'}) + elif res.get('group_purchase_taxes_on_order_line'): + res.update({'tax_policy': 'on_order_line'}) + else: + res.update({'tax_policy': 'no_tax'}) + return res + + + _defaults = { + 'default_invoice_method': lambda s,c,u,ctx: s.pool.get('purchase.order').default_get(c,u,['invoice_method'],context=ctx)['invoice_method'], + 'tax_policy': 'global_on_order', + } + + def _check_default_tax(self, cr, uid, context=None): + ir_values_obj = self.pool.get('ir.values') + for tax in ir_values_obj.get(cr, uid, 'default', False, ['product.product']): + if tax[1] == 'supplier_taxes_id': + return tax[2] + return False + + def set_default_taxes(self, cr, uid, ids, context=None): + ir_values_obj = self.pool.get('ir.values') + taxes = self._check_default_tax(cr, uid, context=context) + if taxes: + ir_values_obj.set(cr, uid, 'default', False, 'tax_id', ['purchase.order'], taxes[0]) + ir_values_obj.set(cr, uid, 'default', False, 'taxes_id', ['purchase.order.line'], taxes) + ir_values_obj.set(cr, uid, 'default', False, 'supplier_taxes_id', ['product.product'], taxes) + + def onchange_tax_policy(self, cr, uid, ids, tax_policy, context=None): + res = {'value': {}} + if tax_policy == 'global_on_order': + res['value'].update({'group_purchase_taxes_global_on_order': True}) + res['value'].update({'group_purchase_taxes_on_order_line': False}) + + elif tax_policy == 'on_order_line': + res['value'].update({'group_purchase_taxes_on_order_line': True}) + res['value'].update({'group_purchase_taxes_global_on_order': False}) + else: + res['value'].update({'group_purchase_taxes_on_order_line': False, 'group_purchase_taxes_global_on_order': False}) + return res + +purchase_configuration() + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file === added file 'purchase/res_config_view.xml' --- purchase/res_config_view.xml 1970-01-01 00:00:00 +0000 +++ purchase/res_config_view.xml 2012-03-13 12:56:53 +0000 @@ -0,0 +1,62 @@ +<openerp> + <data> + + <record id="view_purchase_configuration" model="ir.ui.view"> + <field name="name">Purchase Application</field> + <field name="model">purchase.configuration</field> + <field name="type">form</field> + <field name="arch" type="xml"> + <form string="Purchase Application"> + <separator string="Default Invoicing Control" colspan="4"/> + <group colspan="2" col="4"> + <field name="default_invoice_method" /> + </group> + + <separator string="Purchase Order" colspan="4"/> + <group colspan="4" col="8" name="Purchase_order"> + <group colspan="4" col="4"> + <field name="group_purchase_pricelist_per_supplier"/> + <newline/> + <group col="2" colspan="1"> + <field name="tax_policy" on_change="onchange_tax_policy(tax_policy)"/> + </group> + <field name="group_purchase_taxes_global_on_order" invisible="1"/> + <field name="group_purchase_taxes_on_order_line" invisible="1"/> + <newline/> + <field name="module_warning"/> + <newline/> + <field name="module_purchase_analytic_plans"/> + <newline/> + </group> + <group colspan="4" col="4"> + <newline/> + <field name="group_sale_uom_per_product"/> + <newline/> + <field name="module_purchase_double_validation"/> + <newline/> + <field name="module_purchase_requisition"/> + <newline/> + </group> + </group> + + <separator string="Products" colspan="4"/> + <group colspan="4" col="4"> + <field name="module_product_manufacturer"/> + </group> + </form> + </field> + </record> + + <record id="action_purchase_configuration" model="ir.actions.act_window"> + <field name="name">Configure Purchase Application</field> + <field name="type">ir.actions.act_window</field> + <field name="res_model">purchase.configuration</field> + <field name="view_id" ref="view_purchase_configuration"/> + <field name="view_type">form</field> + <field name="view_mode">form</field> + </record> + + <menuitem id="menu_purchse_config" name="Purchase" parent="base.menu_config" sequence="1" action="action_purchase_configuration"/> + + </data> +</openerp> === modified file 'purchase/security/purchase_security.xml' --- purchase/security/purchase_security.xml 2011-12-19 16:54:40 +0000 +++ purchase/security/purchase_security.xml 2012-03-13 12:56:53 +0000 @@ -12,6 +12,22 @@ <field name="implied_ids" eval="[(4, ref('group_purchase_user'))]"/> </record> + <record id="base.group_purchase_taxes_global_on_order" model="res.groups"> + <field name="name">Purchase Taxes Global on Order</field> + <field name="category_id" ref="base.module_category_hidden"/> + </record> + + <record id="base.group_purchase_taxes_on_order_line" model="res.groups"> + <field name="name">Purchase Taxes on Order Lines</field> + <field name="category_id" ref="base.module_category_hidden"/> + </record> + + <record id="base.group_user" model="res.groups"> + <field name="implied_ids" eval="[(6,0,[ + ref('base.group_purchase_taxes_global_on_order'), + ])]"/> + </record> + <record model="ir.rule" id="purchase_order_comp_rule"> <field name="name">Purchase Order multi-company</field> <field name="model_id" ref="model_purchase_order"/> === modified file 'purchase_double_validation/purchase_double_validation_installer.py' --- purchase_double_validation/purchase_double_validation_installer.py 2010-12-31 06:26:40 +0000 +++ purchase_double_validation/purchase_double_validation_installer.py 2012-03-13 12:56:53 +0000 @@ -22,18 +22,29 @@ from osv import fields, osv class purchase_double_validation_installer(osv.osv_memory): - _name = 'purchase.double.validation.installer' - _inherit = 'res.config' + _inherit = 'purchase.configuration' _columns = { - 'limit_amount': fields.integer('Maximum Purchase Amount', required=True, help="Maximum amount after which validation of purchase is required."), + 'limit_amount': fields.integer('Maximum Purchase Amount',required=True, help="Maximum amount after which validation of purchase is required."), } + def default_get(self, cr, uid, fields, context=None): + data_obj = self.pool.get('ir.model.data') + transition_obj = self.pool.get('workflow.transition') + installed_modules = super(purchase_double_validation_installer, self).default_get(cr, uid, fields, context=context) + if installed_modules.get('module_purchase_double_validation'): + tra_id = data_obj.get_object(cr, uid, 'purchase_double_validation', 'trans_waiting_confirmed') + condition = transition_obj.browse(cr, uid, tra_id.id).condition + con = condition.split('<', 1 ); + installed_modules.update({'limit_amount': int(con[1])}) + return installed_modules + _defaults = { 'limit_amount': 5000, } def execute(self, cr, uid, ids, context=None): data = self.read(cr, uid, ids, context=context) + super(purchase_double_validation_installer, self).execute(cr, uid, ids, context) if not data: return {} amt = data[0]['limit_amount'] @@ -45,7 +56,7 @@ confirm_id = data_pool.browse(cr, uid, confirm, context=context).res_id transition_obj.write(cr, uid, waiting_id, {'condition': 'amount_total>=%s' % (amt)}) transition_obj.write(cr, uid, confirm_id, {'condition': 'amount_total<%s' % (amt)}) - return {} + return True purchase_double_validation_installer() === modified file 'purchase_double_validation/purchase_double_validation_installer.xml' --- purchase_double_validation/purchase_double_validation_installer.xml 2011-10-16 01:28:00 +0000 +++ purchase_double_validation/purchase_double_validation_installer.xml 2012-03-13 12:56:53 +0000 @@ -1,51 +1,17 @@ <openerp> <data> - <!-- configartion view --> - <record id="view_config_purchase_limit_amount" model="ir.ui.view"> - <field name="name">Configure Limit Amount for Purchase</field> - <field name="model">purchase.double.validation.installer</field> + <record id="view_double_purchase_configuration" model="ir.ui.view"> + <field name="name">Purchase Application</field> + <field name="model">purchase.configuration</field> <field name="type">form</field> - <field name="inherit_id" ref="base.res_config_view_base"/> + <field name="inherit_id" ref="purchase.view_purchase_configuration"/> <field name="arch" type="xml"> - <data> - <form position="attributes"> - <attribute name="string">Purchase Application Configuration</attribute> - </form> - <separator string="title" position="attributes"> - <attribute name="string">Configure Limit Amount for Purchase</attribute> - </separator> - <xpath expr="//label[@string='description']" position="attributes"> - <attribute name="string">Define minimum amount after which puchase is needed to be validated.</attribute> - </xpath> - <xpath expr="//separator[@string="vsep"]" position="attributes"> - <attribute name="rowspan">15</attribute> - <attribute name="string"/> - </xpath> - <group string="res_config_contents" position="replace"> - <field name="limit_amount"/> - <newline/> - </group> - </data> + <field name="module_purchase_double_validation" position="after"> + <field name="limit_amount" nolabel="1"/> + </field> </field> </record> - <record id="action_config_purchase_limit_amount" model="ir.actions.act_window"> - <field name="name">Configure Limit Amount for Purchase</field> - <field name="type">ir.actions.act_window</field> - <field name="res_model">purchase.double.validation.installer</field> - <field name="view_id" ref="view_config_purchase_limit_amount"/> - <field name="view_type">form</field> - <field name="view_mode">form</field> - <field name="target">new</field> - </record> - - <!-- register configuration wizard --> - <record id="config_wizard_step_purchase_limit_amount" model="ir.actions.todo"> - <field name="action_id" ref="action_config_purchase_limit_amount"/> - <field name="category_id" ref="purchase.category_purchase_config"/> - <field name="type">once</field> - </record> - </data> </openerp>
_______________________________________________ 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

