[MERGE] staging branch with misc fixes and improevmeents
bzr revid: qdp-launchpad@openerp.com-20120725171054-ulo0febioz2n7wry
This commit is contained in:
commit
e5dcb6d833
|
@ -29,6 +29,8 @@ import pooler
|
|||
from osv import fields, osv
|
||||
import decimal_precision as dp
|
||||
from tools.translate import _
|
||||
from tools.float_utils import float_round
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
def check_cycle(self, cr, uid, ids, context=None):
|
||||
|
@ -2090,7 +2092,7 @@ class account_tax(osv.osv):
|
|||
tax_compute_precision = precision
|
||||
if taxes and taxes[0].company_id.tax_calculation_rounding_method == 'round_globally':
|
||||
tax_compute_precision += 5
|
||||
totalin = totalex = round(price_unit * quantity, precision)
|
||||
totalin = totalex = float_round(price_unit * quantity, precision)
|
||||
tin = []
|
||||
tex = []
|
||||
for tax in taxes:
|
||||
|
|
|
@ -2601,7 +2601,7 @@ action = pool.get('res.config').next(cr, uid, [], context)
|
|||
<h1><field name="name" class="oe_inline" attrs="{'invisible':[('name','=','/')]}"/></h1>
|
||||
<group>
|
||||
<group>
|
||||
<field name="journal_id" on_change="onchange_journal_id(journal_id)" widget="selection"/>
|
||||
<field name="journal_id" on_change="onchange_journal_id(journal_id)" widget="selection" domain="[('type', '=', 'cash')]" />
|
||||
<field name="user_id" readonly="1" string="Responsible"/>
|
||||
<field name="total_entry_encoding"/>
|
||||
<field name='company_id' widget="selection" groups="base.group_multi_company" />
|
||||
|
|
|
@ -38,7 +38,7 @@ transfer this amount to the debtor or creditor account. Secondly, price differen
|
|||
actual purchase price and fixed product standard price are booked on a separate account.""",
|
||||
"images": ["images/account_anglo_saxon.jpeg"],
|
||||
"depends": ["product", "purchase"],
|
||||
"category": "Hidden/Dependency",
|
||||
"category": "Accounting & Finance",
|
||||
"init_xml": [],
|
||||
"demo_xml": [],
|
||||
"update_xml": ["product_view.xml",],
|
||||
|
|
|
@ -258,32 +258,6 @@ class product_template(osv.osv):
|
|||
_name = "product.template"
|
||||
_description = "Product Template"
|
||||
|
||||
def _get_main_product_supplier(self, cr, uid, product, context=None):
|
||||
"""Determines the main (best) product supplier for ``product``,
|
||||
returning the corresponding ``supplierinfo`` record, or False
|
||||
if none were found. The default strategy is to select the
|
||||
supplier with the highest priority (i.e. smallest sequence).
|
||||
|
||||
:param browse_record product: product to supply
|
||||
:rtype: product.supplierinfo browse_record or False
|
||||
"""
|
||||
sellers = [(seller_info.sequence, seller_info)
|
||||
for seller_info in product.seller_ids or []
|
||||
if seller_info and isinstance(seller_info.sequence, (int, long))]
|
||||
return sellers and sellers[0][1] or False
|
||||
|
||||
def _calc_seller(self, cr, uid, ids, fields, arg, context=None):
|
||||
result = {}
|
||||
for product in self.browse(cr, uid, ids, context=context):
|
||||
main_supplier = self._get_main_product_supplier(cr, uid, product, context=context)
|
||||
result[product.id] = {
|
||||
'seller_info_id': main_supplier and main_supplier.id or False,
|
||||
'seller_delay': main_supplier and main_supplier.delay or 1,
|
||||
'seller_qty': main_supplier and main_supplier.qty or 0.0,
|
||||
'seller_id': main_supplier and main_supplier.name.id or False
|
||||
}
|
||||
return result
|
||||
|
||||
_columns = {
|
||||
'name': fields.char('Name', size=128, required=True, translate=True, select=True),
|
||||
'product_manager': fields.many2one('res.users','Product Manager',help="Responsible for product."),
|
||||
|
@ -320,10 +294,6 @@ class product_template(osv.osv):
|
|||
help='Coefficient to convert Unit of Measure to UOS\n'
|
||||
' uos = uom * coeff'),
|
||||
'mes_type': fields.selection((('fixed', 'Fixed'), ('variable', 'Variable')), 'Measure Type', required=True),
|
||||
'seller_info_id': fields.function(_calc_seller, type='many2one', relation="product.supplierinfo", multi="seller_info"),
|
||||
'seller_delay': fields.function(_calc_seller, type='integer', string='Supplier Lead Time', multi="seller_info", 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_qty': fields.function(_calc_seller, type='float', string='Supplier Quantity', multi="seller_info", help="This is minimum quantity to purchase from Main Supplier."),
|
||||
'seller_id': fields.function(_calc_seller, type='many2one', relation="res.partner", string='Main Supplier', help="Main Supplier who has highest priority in Supplier List.", multi="seller_info"),
|
||||
'seller_ids': fields.one2many('product.supplierinfo', 'product_id', 'Partners'),
|
||||
'loc_rack': fields.char('Rack', size=16),
|
||||
'loc_row': fields.char('Row', size=16),
|
||||
|
@ -491,6 +461,34 @@ class product_product(osv.osv):
|
|||
res[p.id] = (data['code'] and ('['+data['code']+'] ') or '') + \
|
||||
(data['name'] or '') + (data['variants'] and (' - '+data['variants']) or '')
|
||||
return res
|
||||
|
||||
|
||||
def _get_main_product_supplier(self, cr, uid, product, context=None):
|
||||
"""Determines the main (best) product supplier for ``product``,
|
||||
returning the corresponding ``supplierinfo`` record, or False
|
||||
if none were found. The default strategy is to select the
|
||||
supplier with the highest priority (i.e. smallest sequence).
|
||||
|
||||
:param browse_record product: product to supply
|
||||
:rtype: product.supplierinfo browse_record or False
|
||||
"""
|
||||
sellers = [(seller_info.sequence, seller_info)
|
||||
for seller_info in product.seller_ids or []
|
||||
if seller_info and isinstance(seller_info.sequence, (int, long))]
|
||||
return sellers and sellers[0][1] or False
|
||||
|
||||
def _calc_seller(self, cr, uid, ids, fields, arg, context=None):
|
||||
result = {}
|
||||
for product in self.browse(cr, uid, ids, context=context):
|
||||
main_supplier = self._get_main_product_supplier(cr, uid, product, context=context)
|
||||
result[product.id] = {
|
||||
'seller_info_id': main_supplier and main_supplier.id or False,
|
||||
'seller_delay': main_supplier and main_supplier.delay or 1,
|
||||
'seller_qty': main_supplier and main_supplier.qty or 0.0,
|
||||
'seller_id': main_supplier and main_supplier.name.id or False
|
||||
}
|
||||
return result
|
||||
|
||||
|
||||
_defaults = {
|
||||
'active': lambda *a: 1,
|
||||
|
@ -526,6 +524,10 @@ class product_product(osv.osv):
|
|||
'name_template': fields.related('product_tmpl_id', 'name', string="Name", type='char', size=128, store=True, select=True),
|
||||
'color': fields.integer('Color Index'),
|
||||
'product_image': fields.binary('Image'),
|
||||
'seller_info_id': fields.function(_calc_seller, type='many2one', relation="product.supplierinfo", multi="seller_info"),
|
||||
'seller_delay': fields.function(_calc_seller, type='integer', string='Supplier Lead Time', multi="seller_info", 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_qty': fields.function(_calc_seller, type='float', string='Supplier Quantity', multi="seller_info", help="This is minimum quantity to purchase from Main Supplier."),
|
||||
'seller_id': fields.function(_calc_seller, type='many2one', relation="res.partner", string='Main Supplier', help="Main Supplier who has highest priority in Supplier List.", multi="seller_info"),
|
||||
}
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
|
|
|
@ -919,15 +919,15 @@ class purchase_order_line(osv.osv):
|
|||
|
||||
qty = qty or 1.0
|
||||
supplierinfo = False
|
||||
supplierinfo_ids = product_supplierinfo.search(cr, uid, [('name','=',partner_id),('product_id','=',product.id)])
|
||||
if supplierinfo_ids:
|
||||
supplierinfo = product_supplierinfo.browse(cr, uid, supplierinfo_ids[0], context=context)
|
||||
if supplierinfo.product_uom.id != uom_id:
|
||||
res['warning'] = {'title': _('Warning'), 'message': _('The selected supplier only sells this product by %s') % supplierinfo.product_uom.name }
|
||||
min_qty = product_uom._compute_qty(cr, uid, supplierinfo.product_uom.id, supplierinfo.min_qty, to_uom_id=uom_id)
|
||||
if qty < min_qty: # If the supplier quantity is greater than entered from user, set minimal.
|
||||
res['warning'] = {'title': _('Warning'), 'message': _('The selected supplier has a minimal quantity set to %s %s, you should not purchase less.') % (supplierinfo.min_qty, supplierinfo.product_uom.name)}
|
||||
qty = min_qty
|
||||
for supplier in product.seller_ids:
|
||||
if supplier.name.id == partner_id:
|
||||
supplierinfo = supplier
|
||||
if supplierinfo.product_uom.id != uom_id:
|
||||
res['warning'] = {'title': _('Warning'), 'message': _('The selected supplier only sells this product by %s') % supplierinfo.product_uom.name }
|
||||
min_qty = product_uom._compute_qty(cr, uid, supplierinfo.product_uom.id, supplierinfo.min_qty, to_uom_id=uom_id)
|
||||
if qty < min_qty: # If the supplier quantity is greater than entered from user, set minimal.
|
||||
res['warning'] = {'title': _('Warning'), 'message': _('The selected supplier has a minimal quantity set to %s %s, you should not purchase less.') % (supplierinfo.min_qty, supplierinfo.product_uom.name)}
|
||||
qty = min_qty
|
||||
|
||||
dt = self._get_date_planned(cr, uid, supplierinfo, date_order, context=context).strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
|
||||
|
|
Loading…
Reference in New Issue