openerp-dev-web team mailing list archive
-
openerp-dev-web team
-
Mailing list archive
-
Message #00477
[Merge] lp:~ovnicraft/openobject-addons/dev-point_of_sale into lp:~openerp-dev/openobject-addons/trunk-dev-addons3
Cristian Salamea (Gnuthink) has proposed merging lp:~ovnicraft/openobject-addons/dev-point_of_sale into lp:~openerp-dev/openobject-addons/trunk-dev-addons3.
Requested reviews:
OpenERP R&D Team (openerp-dev)
Fix code rules and improvements
--
https://code.launchpad.net/~ovnicraft/openobject-addons/dev-point_of_sale/+merge/40926
Your team OpenERP R&D Team is requested to review the proposed merge of lp:~ovnicraft/openobject-addons/dev-point_of_sale into lp:~openerp-dev/openobject-addons/trunk-dev-addons3.
=== modified file 'point_of_sale/point_of_sale.py'
--- point_of_sale/point_of_sale.py 2010-11-10 12:09:02 +0000
+++ point_of_sale/point_of_sale.py 2010-11-16 04:33:56 +0000
@@ -33,6 +33,7 @@
""" Point of Sale journal configuration"""
_name = 'pos.config.journal'
_description = "Journal Configuration"
+
_columns = {
'name': fields.char('Description', size=64),
'code': fields.char('Code', size=64),
@@ -41,9 +42,11 @@
pos_config_journal()
+
class pos_company_discount(osv.osv):
""" Company Discount and Cashboxes """
_inherit = 'res.company'
+
_columns = {
'company_discount': fields.float('Max Discount(%)', digits_compute=dp.get_precision('Point Of Sale')),
'max_diff': fields.float('Max Difference for Cashboxes', digits_compute=dp.get_precision('Point Of Sale Discount')),
@@ -172,20 +175,22 @@
(1-(line.discount or 0.0)/100.0), line.qty),
res[order.id]['amount_tax'])
elif line.qty != 0.0:
- for c in tax_obj.compute_all(cr, uid, line.product_id.taxes_id, line.price_unit * (1-(line.discount or 0.0)/100.0), line.qty, line.product_id, line.order_id.partner_id)['taxes']:
+ for c in tax_obj.compute_all(cr, uid, line.product_id.taxes_id, \
+ line.price_unit * (1-(line.discount or 0.0)/100.0), \
+ line.qty, line.product_id, line.order_id.partner_id)['taxes']:
val += c.get('amount', 0.0)
res[order.id]['amount_tax'] = cur_obj.round(cr, uid, cur, val)
return res
def _sale_journal_get(self, cr, uid, context=None):
- """ To get sale journal for this order"
+ """ To get sale journal for this order
@return: journal """
journal_obj = self.pool.get('account.journal')
res = journal_obj.search(cr, uid, [('type', '=', 'sale')], limit=1)
return res and res[0] or False
def _shop_get(self, cr, uid, context=None):
- """ To get Shop for this order"
+ """ To get Shop for this order
@return: Shop id """
res = self.pool.get('sale.shop').search(cr, uid, [])
return res and res[0] or False
@@ -205,7 +210,7 @@
})
return super(pos_order, self).copy(cr, uid, id, default, context=context)
- def _get_v( self, cr, uid, ids, *a):
+ def _get_v( self, cr, uid, ids, *args):
""" Changed the Validation state of order
@return: State """
res_obj = self.pool.get('res.users')
@@ -241,8 +246,13 @@
'shop_id': fields.many2one('sale.shop', 'Shop', required=True,
states={'draft': [('readonly', False)]}, readonly=True),
'date_order': fields.datetime('Date Ordered', readonly=True),
- 'date_validation': fields.function(_get_date_payment, method=True, string='Validation Date', type='date', store=True),
- 'date_payment': fields.function(_get_date_payment2, method=True, string='Payment Date', type='date', store=True),
+ 'date_validation': fields.function(_get_date_payment,
+ method=True,
+ string='Validation Date',
+ type='date', store=True),
+ 'date_payment': fields.function(_get_date_payment2, method=True,
+ string='Payment Date',
+ type='date', store=True),
'date_validity': fields.date('Validity Date', required=True),
'user_id': fields.many2one('res.users', 'Connected Salesman', help="Person who uses the the cash register. It could be a reliever, a student or an interim employee."),
'user_salesman_id': fields.many2one('res.users', 'Cashier', required=True, help="User who is logged into the system."),
@@ -283,7 +293,7 @@
}
def _select_pricelist(self, cr, uid, context=None):
- """ To get default pricelist for the order"
+ """ To get default pricelist for the order
@param name: Names of fields.
@return: pricelist ID
"""
@@ -291,7 +301,7 @@
return pricelist and pricelist[0] or False
def _journal_default(self, cr, uid, context=None):
- """ To get default pricelist for the order"
+ """ To get default pricelist for the order
@param name: Names of fields.
@return: journal ID
"""
@@ -317,7 +327,7 @@
def test_order_lines(self, cr, uid, order, context=None):
- """ Test order line is created or not for the order "
+ """ Test order line is created or not for the order
@param name: Names of fields.
@return: True
"""
@@ -450,7 +460,7 @@
location_id, stock_dest_id = stock_dest_id, location_id
move_obj.create(cr, uid, {
- 'name': 'Stock move (POS %d)' % (order.id, ),
+ 'name': '(POS %d)' % (order.id, ),
'product_uom': line.product_id.uom_id.id,
'product_uos': line.product_id.uom_id.id,
'picking_id': picking_id,
@@ -504,7 +514,7 @@
def add_payment(self, cr, uid, order_id, data, context=None):
"""Create a new payment for the order"""
- statement_obj= self.pool.get('account.bank.statement')
+ statement_obj = self.pool.get('account.bank.statement')
statement_line_obj = self.pool.get('account.bank.statement.line')
prod_obj = self.pool.get('product.product')
property_obj = self.pool.get('ir.property')
@@ -522,12 +532,15 @@
if 'payment_name' in data.keys():
args['name'] = data['payment_name'] + ' ' + order.name
account_def = property_obj.get(cr, uid, 'property_account_receivable', 'res.partner', context=context)
- args['account_id'] = order.partner_id and order.partner_id.property_account_receivable and order.partner_id.property_account_receivable.id or account_def.id or curr_c.account_receivable.id
+ args['account_id'] = order.partner_id and order.partner_id.property_account_receivable \
+ and order.partner_id.property_account_receivable.id or account_def.id or curr_c.account_receivable.id
if data.get('is_acc', False):
args['is_acc'] = data['is_acc']
- args['account_id'] = prod_obj.browse(cr, uid, data['product_id'], context=context).property_account_income and prod_obj.browse(cr, uid, data['product_id'], context=context).property_account_income.id
+ args['account_id'] = prod_obj.browse(cr, uid, data['product_id'], context=context).property_account_income \
+ and prod_obj.browse(cr, uid, data['product_id'], context=context).property_account_income.id
if not args['account_id']:
- raise osv.except_osv(_('Error'), _('Please provide an account for the product: %s')%(prod_obj.browse(cr, uid, data['product_id'], context=context).name))
+ raise osv.except_osv(_('Error'), _('Please provide an account for the product: %s')% \
+ (prod_obj.browse(cr, uid, data['product_id'], context=context).name))
args['partner_id'] = order.partner_id and order.partner_id.id or None
args['ref'] = order.contract_number or None
@@ -543,6 +556,8 @@
args['statement_id'] = statement_id
args['pos_statement_id'] = order_id
args['journal_id'] = data['journal']
+ args['type'] = 'customer'
+ args['ref'] = order.name
statement_line_obj.create(cr, uid, args, context=context)
ids_new.append(statement_id)
@@ -553,7 +568,9 @@
return statement_id
def add_product(self, cr, uid, order_id, product_id, qty, context=None):
+
"""Create a new order line the order"""
+
line_obj = self.pool.get('pos.order.line')
values = self.read(cr, uid, order_id, ['partner_id', 'pricelist_id'])
@@ -574,7 +591,9 @@
return order_line_id, price
def refund(self, cr, uid, ids, context=None):
+
"""Create a copy of order for refund order"""
+
clone_list = []
line_obj = self.pool.get('pos.order.line')
@@ -599,7 +618,9 @@
return clone_list
def action_invoice(self, cr, uid, ids, context=None):
+
"""Create a invoice of order """
+
inv_ref = self.pool.get('account.invoice')
inv_line_ref = self.pool.get('account.invoice.line')
product_obj = self.pool.get('product.product')
@@ -642,10 +663,10 @@
inv_line.update(inv_line_ref.product_id_change(cr, uid, [],
line.product_id.id,
line.product_id.uom_id.id,
- line.qty, partner_id = order.partner_id.id, fposition_id=order.partner_id.property_account_position.id)['value'])
+ line.qty, partner_id = order.partner_id.id,
+ fposition_id=order.partner_id.property_account_position.id)['value'])
inv_line['price_unit'] = line.price_unit
inv_line['discount'] = line.discount
- inv_line['account_id'] = acc
inv_line['name'] = inv_name
inv_line['invoice_line_tax_id'] = ('invoice_line_tax_id' in inv_line)\
and [(6, 0, inv_line['invoice_line_tax_id'])] or []
=== modified file 'point_of_sale/point_of_sale_view.xml'
--- point_of_sale/point_of_sale_view.xml 2010-11-15 13:59:05 +0000
+++ point_of_sale/point_of_sale_view.xml 2010-11-16 04:33:56 +0000
@@ -17,6 +17,8 @@
<field name="shop_id" widget="selection"/>
<field name="partner_id" on_change="onchange_partner_pricelist(partner_id)"/>
<field name="contract_number" groups="base.group_extended"/>
+ <button name="%(point_of_sale.action_pos_scan_product)d" string="Scan Barcode" type="action" states="draft,advance"/>
+ <button name="%(point_of_sale.action_add_product)d" string="Add Product" type="action" states="draft,advance"/>
</group>
<notebook colspan="4">
<page string="Sale Order">
=== modified file 'point_of_sale/wizard/pos_add_product.py'
--- point_of_sale/wizard/pos_add_product.py 2010-11-15 13:59:05 +0000
+++ point_of_sale/wizard/pos_add_product.py 2010-11-16 04:33:56 +0000
@@ -81,6 +81,7 @@
obj = order_obj.browse(cr, uid, record_id, context=context)
order_obj.write(cr, uid, [record_id], {'state': 'done'}, context=context)
+<<<<<<< TREE
return {
'name': _('Make Payment'),
'context': context and context.get('active_id', False),
@@ -92,6 +93,19 @@
'views': False,
'type': 'ir.actions.act_window',
}
+=======
+ return {
+ 'name': _('Make Payment'),
+ 'context': context and context.get('active_id', False),
+ 'view_type': 'form',
+ 'view_mode': 'form',
+ 'res_model': 'pos.make.payment',
+ 'view_id': False,
+ 'target': 'new',
+ 'views': False,
+ 'type': 'ir.actions.act_window',
+ }
+>>>>>>> MERGE-SOURCE
add_product()
=== modified file 'point_of_sale/wizard/pos_scan_product.py'
--- point_of_sale/wizard/pos_scan_product.py 2010-04-01 12:46:18 +0000
+++ point_of_sale/wizard/pos_scan_product.py 2010-11-16 04:33:56 +0000
@@ -25,9 +25,11 @@
class pos_scan_product(osv.osv_memory):
_name = 'pos.scan.product'
_description = 'Scan product'
+
_columns = {
- 'gencod': fields.char('Barcode',size=13,required= True)
+ 'gencod': fields.char('Barcode', size=13, required=True)
}
+
def scan(self, cr, uid, ids, context):
"""
To get the gencod and scan product
@@ -38,10 +40,11 @@
@return : retrun gencod
"""
- data=self.read(cr, uid, ids)[0]
- record_id = context and context.get('active_id',False)
+ data = self.read(cr, uid, ids)[0]
+ record_id = context and context.get('active_id', False)
result =self. pool.get('pos.order.line')._scan_product(cr, uid, data['gencod'], 1, record_id)
return {'gencod': False}
+
pos_scan_product()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: