[imp] Added POS category

bzr revid: mit@openerp.com-20110718161746-megdu9xb1jeu19g9
This commit is contained in:
Minh Tran 2011-07-18 18:17:46 +02:00
parent ab3cab8955
commit 43f0746480
2 changed files with 52 additions and 17 deletions

View File

@ -425,15 +425,12 @@ class pos_order(osv.osv):
move_obj = self.pool.get('stock.move')
pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.out')
orders = self.browse(cr, uid, ids, context=context)
partner_obj = self.pool.get('res.partner')
for order in orders:
addr = order.partner_id and partner_obj.address_get(cr, uid, [order.partner_id.id], ['delivery']) or {}
if not order.picking_id:
new = True
picking_id = picking_obj.create(cr, uid, {
'name': pick_name,
'origin': order.name,
'address_id': addr.get('delivery',False),
'type': 'out',
'state': 'draft',
'move_type': 'direct',
@ -479,7 +476,6 @@ class pos_order(osv.osv):
'state': 'waiting',
'location_id': location_id,
'location_dest_id': stock_dest_id,
'prodlot_id': line.prodlot_id and line.prodlot_id.id or False
}, context=context)
wf_service = netsvc.LocalService("workflow")
@ -650,7 +646,6 @@ class pos_order(osv.osv):
'reference': order.name,
'partner_id': order.partner_id.id,
'comment': order.note or '',
'currency_id': order.pricelist_id.currency_id.id, # considering partner's sale pricelist's currency
}
inv.update(inv_ref.onchange_partner_id(cr, uid, [], 'out_invoice', order.partner_id.id)['value'])
if not inv.get('account_id', None):
@ -897,13 +892,13 @@ class pos_order(osv.osv):
for pos in self.browse(cr, uid, ids, context=context):
create_contract_nb = False
for line in pos.lines:
if line.product_id.product_type == 'MD':
if line.product_id.type == 'MD':
create_contract_nb = True
break
if create_contract_nb:
seq = sequence_obj.get(cr, uid, 'pos.user_%s' % pos.user_salesman_id.login)
vals['contract_number'] = '%s-%s' % (pos.user_salesman_id.login, seq)
self.write(cr, uid, ids, vals, context=context)
return self.write(cr, uid, ids, vals, context=context)
def action_paid(self, cr, uid, ids, context=None):
if context is None:
@ -1149,7 +1144,6 @@ class pos_order_line(osv.osv):
'discount': fields.float('Discount (%)', digits=(16, 2)),
'order_id': fields.many2one('pos.order', 'Order Ref', ondelete='cascade'),
'create_date': fields.datetime('Creation Date', readonly=True),
'prodlot_id': fields.many2one('stock.production.lot', 'Production Lot', help="You can specify Production lot for stock move created when you validate the pos order"),
}
_defaults = {
@ -1226,6 +1220,15 @@ class pos_order_line(osv.osv):
pos_order_line()
class pos_category(osv.osv):
_name = 'pos.category'
_inherit = 'product.category'
_columns = {
'parent_id': fields.many2one('pos.category','Parent Category', select=True),
'child_id': fields.one2many('pos.category', 'parent_id', string='Child Categories'),
}
pos_category()
class product_product(osv.osv):
_inherit = 'product.product'
_columns = {
@ -1233,9 +1236,13 @@ class product_product(osv.osv):
'expense_pdt': fields.boolean('Product for expenses'),
'am_out': fields.boolean('Control for Output Operations'),
'disc_controle': fields.boolean('Discount Control'),
'img': fields.binary('Pos Image, must be 50x50'),
'pos_ok': fields.boolean('Can be POS-sold'),
'pos_categ_id': fields.many2one('pos.category','POS Category', change_default=True, domain="[('type','=','normal')]" ,help="Select a pos category for the current product")
}
_defaults = {
'disc_controle': True,
'pos_ok': True,
}
product_product()

View File

@ -41,7 +41,6 @@
<field name="price_unit"/>
<field name="notice"/>
<field name="serial_number"/>
<field name="prodlot_id" domain="[('product_id','=',product_id)]"/>
</form>
</field>
<group colspan="4" col="7">
@ -89,7 +88,7 @@
</group>
<group colspan="4">
<field name="sale_journal" domain="[('type','=','sale')]" widget="selection" invisible="1"/>
<field name="pricelist_id" domain="[('type','=','sale')]" widget="selection" invisible="0"/>
<field name="pricelist_id" domain="[('type','=','sale')]" widget="selection" invisible="1"/>
</group>
</page>
<page string="Notes" >
@ -639,11 +638,12 @@
<field name="type">form</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<field name="currency_id" position="after">
<separator string="Point of Sale" colspan="4"/>
<field name="company_discount" />
<field name="max_diff" />
</field>
<notebook position="inside">
<page string="Other">
<field name="company_discount" colspan="4"/>
<field name="max_diff" colspan="4"/>
</page>
</notebook>
</field>
</record>
@ -653,16 +653,44 @@
<field name="type">form</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<field name="company_id" position="after">
<separator string="Point of Sale" colspan="2"/>
<field name="purchase_ok" position="after">
<field name="pos_ok"/>
</field>
<field name="active" position="after">
<field name="income_pdt"/>
<field name="expense_pdt"/>
<field name="am_out"/>
<field name="disc_controle"/>
<field name="img"/>
<field name="pos_categ_id" />
</field>
</field>
</record>
<!-- Categories tree view -->
<record id="pos_category_tree_view" model="ir.ui.view">
<field name="name">pos.category.tree</field>
<field name="model">pos.category</field>
<field name="type">tree</field>
<field name="field_parent">child_id</field>
<field name="arch" type="xml">
<tree toolbar="True" string="Product Pos Categories">
<field name="name"/>
</tree>
</field>
</record>
<record id="pos_category_action" model="ir.actions.act_window">
<field name="name">Products by POS-Category</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">pos.category</field>
<field name="domain">[('parent_id','=',False)]</field>
<field name="view_type">tree</field>
<field name="view_id" ref="pos_category_tree_view"/>
<field name="help">Here is a list of all your products classified by POS category. You can click a category to get the list of all products linked to this category or to a child of this category.</field>
</record>
<menuitem action="pos_category_action" id="menu_pos_category" parent="menu_point_of_sale_product" sequence="0" />
<!-- END -->
<record id="product_input_output_form_view" model="ir.ui.view">
<field name="name">product.normal.form.inherit</field>
<field name="model">product.product</field>