View Improvement

bzr revid: fp@tinyerp.com-20080824232345-v3f5phajqy2mo9kr
This commit is contained in:
Fabien Pinckaers 2008-08-25 01:23:45 +02:00
parent 45cd43be4c
commit 0ff09fd6a9
6 changed files with 195 additions and 105 deletions

View File

@ -7,12 +7,19 @@
<field name="type">form</field> <field name="type">form</field>
<field name="inherit_id" ref="product.product_normal_form_view"/> <field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="product_manager" position="after"> <notebook position="inside">
<newline/> <page string="Accounting">
<field colspan="4" name="supplier_taxes_id"/> <separator string="Sales" colspan="2"/>
<field colspan="4" name="taxes_id"/> <separator string="Purchases" colspan="2"/>
<newline/> <field name="property_account_income"/>
</field> <field name="property_account_expense"/>
<separator string="Sale Taxes" colspan="2"/>
<separator string="Purchase Taxes" colspan="2"/>
<field name="taxes_id" nolabel="1" colspan="2"/>
<field name="supplier_taxes_id" nolabel="1" colspan="2"/>
</page>
</notebook>
</field> </field>
</record> </record>
@ -22,13 +29,17 @@
<field name="type">form</field> <field name="type">form</field>
<field name="inherit_id" ref="product.product_template_form_view"/> <field name="inherit_id" ref="product.product_template_form_view"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<field name="cost_method" position="after"> <notebook position="inside">
<newline/> <page string="Accounting">
<field colspan="4" name="supplier_taxes_id"/> <separator string="Sales" colspan="2"/>
<field colspan="4" name="taxes_id"/> <separator string="Purchases" colspan="2"/>
<newline/> <field name="property_account_income"/>
</field> <field name="property_account_expense"/>
</field> <field name="supplier_taxes_id"/>
<field name="taxes_id"/>
</page>
</notebook>
</field>
</record> </record>
@ -46,39 +57,5 @@
</field> </field>
</record> </record>
<record id="view_template_property_form" model="ir.ui.view">
<field name="name">product.template.property.form.inherit</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">
<page string="Properties" position="inside">
<separator string="Sales Properties" colspan="2"/>
<separator string="Purchases Properties" colspan="2"/>
<field name="property_account_income"/>
<field name="property_account_expense"/>
</page>
</field>
</record>
<record id="view_normal_property_form" model="ir.ui.view">
<field name="name">product.normal.property.form.inherit</field>
<field name="model">product.product</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<page string="Properties" position="inside">
<separator string="Sales Properties" colspan="2"/>
<separator string="Purchases Properties" colspan="2"/>
<field name="property_account_income"/>
<field name="property_account_expense"/>
</page>
</field>
</record>
</data> </data>
</terp> </terp>

View File

@ -246,12 +246,12 @@ class product_template(osv.osv):
'description_sale': fields.text('Sale Description'), 'description_sale': fields.text('Sale Description'),
'type': fields.selection([('product','Stockable Product'),('consu', 'Consumable'),('service','Service')], 'Product Type', required=True), 'type': fields.selection([('product','Stockable Product'),('consu', 'Consumable'),('service','Service')], 'Product Type', required=True),
'supply_method': fields.selection([('produce','Produce'),('buy','Buy')], 'Supply method', required=True), 'supply_method': fields.selection([('produce','Produce'),('buy','Buy')], 'Supply method', required=True),
'sale_delay': fields.float('Customer lead time', help="This is the average time between the confirmation of the customer order and the delivery of the finnished products. It's the time you promise to your customers."), 'sale_delay': fields.float('Customer Lead Time', help="This is the average time between the confirmation of the customer order and the delivery of the finnished products. It's the time you promise to your customers."),
'produce_delay': fields.float('Manufacturing lead time', help="Average time to produce this product. This is only for the production order and, if it is a multi-level bill of material, it's only for the level of this product. Different delays will be summed for all levels and purchase orders."), 'produce_delay': fields.float('Manufacturing Lead Time', help="Average time to produce this product. This is only for the production order and, if it is a multi-level bill of material, it's only for the level of this product. Different delays will be summed for all levels and purchase orders."),
'procure_method': fields.selection([('make_to_stock','Make to Stock'),('make_to_order','Make to Order')], 'Procure Method', required=True, help="'Make to Stock': When needed, take from the stock or wait until refurnishing. 'Make to Order': When needed, purchase or produce for the procurement request."), 'procure_method': fields.selection([('make_to_stock','Make to Stock'),('make_to_order','Make to Order')], 'Procure Method', required=True, help="'Make to Stock': When needed, take from the stock or wait until refurnishing. 'Make to Order': When needed, purchase or produce for the procurement request."),
'rental': fields.boolean('Rentable product'), 'rental': fields.boolean('Rentable product'),
'categ_id': fields.many2one('product.category','Category', required=True, change_default=True), 'categ_id': fields.many2one('product.category','Category', required=True, change_default=True),
'list_price': fields.float('Public Price', digits=(16, int(config['price_accuracy']))), 'list_price': fields.float('Sale Price', digits=(16, int(config['price_accuracy']))),
'standard_price': fields.float('Cost Price', required=True, digits=(16, int(config['price_accuracy']))), 'standard_price': fields.float('Cost Price', required=True, digits=(16, int(config['price_accuracy']))),
'volume': fields.float('Volume'), 'volume': fields.float('Volume'),
'weight': fields.float('Gross weight'), 'weight': fields.float('Gross weight'),
@ -268,10 +268,13 @@ class product_template(osv.osv):
'uos_coeff': fields.float('UOM -> UOS Coeff', digits=(16,4), 'uos_coeff': fields.float('UOM -> UOS Coeff', digits=(16,4),
help='Coefficient to convert UOM to UOS\n' help='Coefficient to convert UOM to UOS\n'
' uom = uos * coeff'), ' uom = uos * coeff'),
'mes_type': fields.selection((('fixed', 'Fixed'), ('variable', 'Variable')), 'Measure type', required=True), 'mes_type': fields.selection((('fixed', 'Fixed'), ('variable', 'Variable')), 'Measure Type', required=True),
'tracking': fields.boolean('Track lots'), 'tracking': fields.boolean('Track Lots', help="Force to use a Production Lot number during stock operations for traceability."),
'seller_delay': fields.function(_calc_seller_delay, method=True, type='integer', string='Supplier lead time', help="This is the average delay in days between the purchase order confirmation and the reception of goods for this product and for the default supplier. It is used by the scheduler to order requests based on reordering delays."), 'seller_delay': fields.function(_calc_seller_delay, method=True, type='integer', string='Supplier Lead Time', help="This is the average delay in days between the purchase order confirmation and the reception of goods for this product and for the default supplier. It is used by the scheduler to order requests based on reordering delays."),
'seller_ids': fields.one2many('product.supplierinfo', 'product_id', 'Partners'), 'seller_ids': fields.one2many('product.supplierinfo', 'product_id', 'Partners'),
'loc_rack': fields.char('Rack', size=16),
'loc_row': fields.char('Row', size=16),
'loc_case': fields.char('Case', size=16),
} }
def _get_uom_id(self, cr, uid, *args): def _get_uom_id(self, cr, uid, *args):
@ -410,8 +413,8 @@ class product_product(osv.osv):
'product_tmpl_id': fields.many2one('product.template', 'Product Template', required=True), 'product_tmpl_id': fields.many2one('product.template', 'Product Template', required=True),
'ean13': fields.char('EAN13', size=13), 'ean13': fields.char('EAN13', size=13),
'packaging' : fields.one2many('product.packaging', 'product_id', 'Palettization', help="Gives the different ways to package the same product. This has no impact on the packing order and is mainly used if you use the EDI module."), 'packaging' : fields.one2many('product.packaging', 'product_id', 'Palettization', help="Gives the different ways to package the same product. This has no impact on the packing order and is mainly used if you use the EDI module."),
'price_extra': fields.float('Price Extra', digits=(16, int(config['price_accuracy']))), 'price_extra': fields.float('Variant Price Extra', digits=(16, int(config['price_accuracy']))),
'price_margin': fields.float('Price Margin', digits=(16, int(config['price_accuracy']))), 'price_margin': fields.float('Variant Price Margin', digits=(16, int(config['price_accuracy']))),
} }
def onchange_uom(self, cursor, user, ids, uom_id,uom_po_id): def onchange_uom(self, cursor, user, ids, uom_id,uom_po_id):
@ -580,7 +583,7 @@ class product_supplierinfo(osv.osv):
'qty' : fields.float('Minimal quantity', required=True), 'qty' : fields.float('Minimal quantity', required=True),
'product_id' : fields.many2one('product.template', 'Product', required=True, ondelete='cascade', select=True), 'product_id' : fields.many2one('product.template', 'Product', required=True, ondelete='cascade', select=True),
'delay' : fields.integer('Delivery delay', required=True), 'delay' : fields.integer('Delivery delay', required=True),
'pricelist_ids': fields.one2many('pricelist.partnerinfo', 'suppinfo_id', 'Pricelist'), 'pricelist_ids': fields.one2many('pricelist.partnerinfo', 'suppinfo_id', 'Supplier Pricelist'),
} }
_defaults = { _defaults = {
'qty': lambda *a: 0.0, 'qty': lambda *a: 0.0,

View File

@ -31,44 +31,84 @@
<field eval="7" name="priority"/> <field eval="7" name="priority"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<form string="Product"> <form string="Product">
<group colspan="2" col="4">
<separator string="Product Description" colspan="4"/>
<field name="name" select="1"/>
<field name="default_code" select="1"/>
<field groups="base.group_extended" name="variants" select="2"/>
<field groups="base.group_extended" name="ean13" select="2"/>
</group>
<group colspan="2" col="2">
<separator string="Product Type" colspan="2"/>
<field name="sale_ok" select="2"/>
<field name="purchase_ok" select="2"/>
<field groups="base.group_extended" name="rental" select="2"/>
</group>
<notebook> <notebook>
<page string="Information"> <page string="Information">
<field name="name" select="1"/> <group colspan="2" col="2">
<field name="default_code" select="1"/> <separator string="Procurement" colspan="2"/>
<field groups="base.group_extended" name="variants" select="2"/> <field name="type" select="2"/>
<field groups="base.group_extended" name="ean13" select="2"/> <field name="procure_method"/>
<newline/> <field name="supply_method"/>
<field name="categ_id" select="1"/> </group>
<field name="type" select="2"/>
<field digits="(14, 3)" groups="base.group_extended" name="volume" attrs="{'readonly':[('type','=','service')]}"/> <group colspan="2" col="2">
<newline/> <separator string="Weigths" colspan="2"/>
<field digits="(14, 3)" groups="base.group_extended" name="weight" attrs="{'readonly':[('type','=','service')]}"/> <field digits="(14, 3)" groups="base.group_extended" name="volume" attrs="{'readonly':[('type','=','service')]}"/>
<field digits="(14, 3)" groups="base.group_extended" name="weight_net" attrs="{'readonly':[('type','=','service')]}"/> <field digits="(14, 3)" groups="base.group_extended" name="weight" attrs="{'readonly':[('type','=','service')]}"/>
<field name="procure_method"/> <field digits="(14, 3)" groups="base.group_extended" name="weight_net" attrs="{'readonly':[('type','=','service')]}"/>
<field name="state" select="2"/> </group>
<field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)"/>
<field name="uom_po_id"/> <group colspan="2" col="2" name="status">
<field groups="base.group_extended" name="product_manager" select="2"/> <separator string="Status" colspan="2"/>
<field name="categ_id" select="1"/>
<field name="state" select="2"/>
<field groups="base.group_extended" name="product_manager" select="2"/>
</group>
<group colspan="2" col="2" name="uom">
<separator string="Lots" colspan="2"/>
<field name="uom_id" on_change="onchange_uom(uom_id,uom_po_id)"/>
<field name="uom_po_id"/>
<field name="tracking"/>
</group>
<group colspan="2" col="2" name="uom">
<separator string="Second UoM" colspan="2"/>
<field name="uos_id"/>
<field name="uos_coeff"/>
<field name="mes_type"/>
</group>
</page> </page>
<page string="Procurement"> <page string="Procurement &amp; Locations">
<field name="supply_method"/> <group colspan="2" col="2" name="delay">
<field name="active" select="2"/> <separator string="Delays" colspan="2"/>
<newline/> <field name="sale_delay" attrs="{'readonly':[('sale_ok','=',0)]}"/>
<field name="sale_delay" attrs="{'readonly':[('sale_ok','=',0)]}"/> <field name="produce_delay"/>
<field name="sale_ok" select="2"/> <field name="warranty"/>
<field name="produce_delay"/> </group>
<field name="purchase_ok" select="2"/> <group colspan="2" col="2" name="store">
<field name="warranty"/> <separator string="Storage Localisation" colspan="2"/>
<field groups="base.group_extended" name="rental" select="2"/> <field name="loc_rack"/>
<newline/> <field name="loc_row"/>
<field name="list_price"/> <field name="loc_case"/>
</group>
<group colspan="2" col="2" name="misc">
<separator string="Miscelleanous" colspan="2"/>
<field name="active" select="2"/>
</group>
</page>
<page string="Prices">
<separator string="Base Prices" colspan="4"/>
<field name="standard_price"/> <field name="standard_price"/>
<field name="list_price"/>
<field groups="base.group_extended" name="cost_method"/> <field groups="base.group_extended" name="cost_method"/>
<newline/> <newline/>
<field groups="base.group_uos" name="uos_id"/> <field colspan="4" name="seller_ids" nolabel="1" mode="form,tree"/>
<field groups="base.group_uos" name="uos_coeff"/>
<newline/>
<field colspan="4" name="seller_ids" nolabel="1" widget="one2many_list"/>
</page> </page>
<page string="Descriptions"> <page string="Descriptions">
<separator string="Description"/> <separator string="Description"/>
@ -79,8 +119,6 @@
<field colspan="4" name="description_purchase" nolabel="1"/> <field colspan="4" name="description_purchase" nolabel="1"/>
</page> </page>
<page groups="base.group_extended" string="Packaging"> <page groups="base.group_extended" string="Packaging">
<field name="mes_type"/>
<field name="tracking"/>
<field colspan="4" name="packaging" nolabel="1"> <field colspan="4" name="packaging" nolabel="1">
<form string="Packaging"> <form string="Packaging">
<field name="ean" select="1"/> <field name="ean" select="1"/>
@ -101,8 +139,6 @@
</form> </form>
</field> </field>
</page> </page>
<page groups="base.group_extended" string="Properties">
</page>
</notebook> </notebook>
</form> </form>
</field> </field>
@ -438,8 +474,6 @@
<separator string="Purchase Description"/> <separator string="Purchase Description"/>
<field colspan="4" name="description_purchase" nolabel="1"/> <field colspan="4" name="description_purchase" nolabel="1"/>
</page> </page>
<page string="Properties">
</page>
</notebook> </notebook>
</form> </form>
</field> </field>

View File

@ -102,6 +102,49 @@ class sale_order(osv.osv):
res[id] = cur_obj.round(cr, uid, cur, untax.get(id, 0.0) + tax.get(id, 0.0)) res[id] = cur_obj.round(cr, uid, cur, untax.get(id, 0.0) + tax.get(id, 0.0))
return res return res
def _picked_rate(self, cr, uid, ids, name, arg, context=None):
if not ids: return {}
res = {}
for id in ids:
res[id] = [0.0,0.0]
cr.execute('''SELECT
p.sale_id,sum(m.product_qty), m.state
FROM
stock_move m
LEFT JOIN
stock_picking p on (p.id=m.picking_id)
WHERE
p.sale_id in ('''+','.join(map(str,ids))+''')
GROUP BY m.state, p.sale_id''')
for oid,nbr,state in cr.fetchall():
if state=='cancel':
continue
if state=='done':
res[oid][0] += nbr or 0.0
res[oid][1] += nbr or 0.0
else:
res[oid][1] += nbr or 0.0
print res
for r in res:
if not res[r][1]:
res[r] = 0.0
else:
res[r] = 100.0 * res[r][0] / res[r][1]
return res
def _invoiced_rate(self, cursor, user, ids, name, arg, context=None):
res = {}
for sale in self.browse(cursor, user, ids, context=context):
tot = 0.0
for invoice in sale.invoice_ids:
if invoice.state not in ('draft','cancel'):
tot += invoice.amount_untaxed
if tot:
res[sale.id] = tot * 100.0 / sale.amount_untaxed
else:
res[sale.id] = 0.0
return res
def _invoiced(self, cursor, user, ids, name, arg, context=None): def _invoiced(self, cursor, user, ids, name, arg, context=None):
res = {} res = {}
for sale in self.browse(cursor, user, ids, context=context): for sale in self.browse(cursor, user, ids, context=context):
@ -187,6 +230,8 @@ class sale_order(osv.osv):
'invoice_ids': fields.many2many('account.invoice', 'sale_order_invoice_rel', 'order_id', 'invoice_id', 'Invoice', help="This is the list of invoices that have been generated for this sale order. The same sale order may have been invoiced in several times (by line for example)."), 'invoice_ids': fields.many2many('account.invoice', 'sale_order_invoice_rel', 'order_id', 'invoice_id', 'Invoice', help="This is the list of invoices that have been generated for this sale order. The same sale order may have been invoiced in several times (by line for example)."),
'picking_ids': fields.one2many('stock.picking', 'sale_id', 'Packing List', readonly=True, help="This is the list of picking list that have been generated for this invoice"), 'picking_ids': fields.one2many('stock.picking', 'sale_id', 'Packing List', readonly=True, help="This is the list of picking list that have been generated for this invoice"),
'shipped':fields.boolean('Picked', readonly=True), 'shipped':fields.boolean('Picked', readonly=True),
'picked_rate': fields.function(_picked_rate, method=True, string='Picked', type='float'),
'invoiced_rate': fields.function(_invoiced_rate, method=True, string='Invoiced', type='float'),
'invoiced': fields.function(_invoiced, method=True, string='Paid', 'invoiced': fields.function(_invoiced, method=True, string='Paid',
fnct_search=_invoiced_search, type='boolean'), fnct_search=_invoiced_search, type='boolean'),
'note': fields.text('Notes'), 'note': fields.text('Notes'),

View File

@ -54,8 +54,8 @@
<field name="name"/> <field name="name"/>
<field name="partner_id"/> <field name="partner_id"/>
<field name="partner_shipping_id"/> <field name="partner_shipping_id"/>
<field name="shipped"/> <field name="picked_rate" widget="progressbar"/>
<field name="invoiced"/> <field name="invoiced_rate" widget="progressbar"/>
<field name="amount_untaxed"/> <field name="amount_untaxed"/>
<field name="state"/> <field name="state"/>
</tree> </tree>

View File

@ -38,21 +38,52 @@
</record> </record>
<record id="view_normal_property_acc.form" model="ir.ui.view">
<field name="name">product.normal.stock.acc.property.form.inherit</field>
<field name="model">product.product</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<field name="property_account_expense" position="after">
<separator string="Accounting Entries" colspan="4"/>
<field name="property_stock_account_input"/>
<field name="property_stock_account_output"/>
</field>
</field>
</record>
<record id="view_normal_stock_property_form" model="ir.ui.view">
<field name="name">product.normal.stock.form.inherit</field>
<field name="model">product.product</field>
<field name="type">form</field>
<field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml">
<group name="status" position="after">
<group colspan="2" col="2">
<separator string="Stocks" colspan="4"/>
<field name="qty_available"/>
<field name="virtual_available"/>
<field name="incoming_qty"/>
<field name="outgoing_qty"/>
</group>
</group>
</field>
</record>
<record id="view_normal_property_form" model="ir.ui.view"> <record id="view_normal_property_form" model="ir.ui.view">
<field name="name">product.normal.stock.property.form.inherit</field> <field name="name">product.normal.stock.property.form.inherit</field>
<field name="model">product.product</field> <field name="model">product.product</field>
<field name="type">form</field> <field name="type">form</field>
<field name="inherit_id" ref="product.product_normal_form_view"/> <field name="inherit_id" ref="product.product_normal_form_view"/>
<field name="arch" type="xml"> <field name="arch" type="xml">
<page string="Properties" position="inside"> <group name="store" position="after">
<separator string="Counter-Part Locations" colspan="4"/> <group col="2" colspan="2" name="store">
<field name="property_stock_procurement"/> <separator string="Counter-Part Locations" colspan="2"/>
<field name="property_stock_production"/> <field name="property_stock_procurement"/>
<field name="property_stock_inventory"/> <field name="property_stock_production"/>
<separator string="Accounting Entries" colspan="4"/> <field name="property_stock_inventory"/>
<field name="property_stock_account_input"/> </group>
<field name="property_stock_account_output"/> </group>
</page>
</field> </field>
</record> </record>