[MERGE] from stw
bzr revid: fva@openerp.com-20120628123912-pn1rzfji2xt7lv76
This commit is contained in:
commit
c753d215dd
|
@ -28,6 +28,10 @@ class CashBox(osv.osv_memory):
|
|||
def _run(self, cr, uid, ids, records, context=None):
|
||||
for box in self.browse(cr, uid, ids, context=context):
|
||||
for record in records:
|
||||
if not record.journal_id:
|
||||
raise osv.except_osv(_('Error !'),
|
||||
_("Please check that the field 'Journal' is set on the Bank Statement"))
|
||||
|
||||
if not record.journal_id.internal_account_id:
|
||||
raise osv.except_osv(_('Error !'),
|
||||
_("Please check that the field 'Internal Transfers Account' is set on the payment method '%s'.") % (record.journal_id.name,))
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#
|
||||
##############################################################################
|
||||
import pdb
|
||||
import io
|
||||
import addons
|
||||
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
@ -1133,6 +1135,8 @@ class pos_order_line(osv.osv):
|
|||
pos_order_line()
|
||||
|
||||
class pos_category(osv.osv):
|
||||
PHOTO_SIZE_HEIGHT = 540
|
||||
PHOTO_SIZE_WIDTH = 450
|
||||
_name = 'pos.category'
|
||||
_description = "Point of Sale Category"
|
||||
_order = "sequence, name"
|
||||
|
@ -1150,6 +1154,38 @@ class pos_category(osv.osv):
|
|||
(_check_recursion, 'Error ! You cannot create recursive categories.', ['parent_id'])
|
||||
]
|
||||
|
||||
def onchange_photo(self, cr, uid, ids, value, context=None):
|
||||
if not value:
|
||||
return {'value': {'photo_big': value, 'photo': value} }
|
||||
return {
|
||||
'value': {
|
||||
'photo_big': self._photo_resize(cr, uid, value, self.PHOTO_SIZE_HEIGHT, self.PHOTO_SIZE_WIDTH, context=context),
|
||||
'photo': self._photo_resize(cr, uid, value, context=context)
|
||||
}
|
||||
}
|
||||
|
||||
def _set_photo(self, cr, uid, id, name, value, args, context=None):
|
||||
if not value:
|
||||
vals = {'photo_big': value}
|
||||
else:
|
||||
vals = {'photo_big': self._photo_resize(cr, uid, value, self.PHOTO_SIZE_HEIGHT, self.PHOTO_SIZE_WIDTH, context=context)}
|
||||
return self.write(cr, uid, [id], vals, context=context)
|
||||
|
||||
def _photo_resize(self, cr, uid, photo, heigth=180, width=150, context=None):
|
||||
image_stream = io.BytesIO(photo.decode('base64'))
|
||||
img = Image.open(image_stream)
|
||||
img.thumbnail((heigth, width), Image.ANTIALIAS)
|
||||
img_stream = StringIO.StringIO()
|
||||
img.save(img_stream, "JPEG")
|
||||
return img_stream.getvalue().encode('base64')
|
||||
|
||||
def _get_photo(self, cr, uid, ids, name, args, context=None):
|
||||
result = dict.fromkeys(ids, False)
|
||||
for category in self.browse(cr, uid, ids, context=context):
|
||||
if category.photo_big:
|
||||
result[category.id] = self._photo_resize(cr, uid, category.photo_big, context=context)
|
||||
return result
|
||||
|
||||
def name_get(self, cr, uid, ids, context=None):
|
||||
if not len(ids):
|
||||
return []
|
||||
|
@ -1172,7 +1208,22 @@ class pos_category(osv.osv):
|
|||
'parent_id': fields.many2one('pos.category','Parent Category', select=True),
|
||||
'child_id': fields.one2many('pos.category', 'parent_id', string='Children Categories'),
|
||||
'sequence': fields.integer('Sequence', help="Gives the sequence order when displaying a list of product categories."),
|
||||
'photo_big': fields.binary('Big-sized employee photo', help="This field holds the photo of the employee. The photo field is used as an interface to access this field. The image is base64 encoded, and PIL-supported. Full-sized photo are however resized to 540x450 px."),
|
||||
'photo': fields.function(_get_photo, fnct_inv=_set_photo, string='Employee photo', type="binary",
|
||||
store = {
|
||||
'hr.employee': (lambda self, cr, uid, ids, c={}: ids, ['photo_big'], 10),
|
||||
}, help="Image used as photo for the employee. It is automatically resized as a 180x150 px image. A larger photo is stored inside the photo_big field."),
|
||||
}
|
||||
|
||||
def _default_photo(self, cr, uid, context=None):
|
||||
photo_path = addons.get_module_resource('point_of_sale','images','default_category_photo.png')
|
||||
return self._photo_resize(cr, uid, open(photo_path, 'rb').read().encode('base64'), context=context)
|
||||
|
||||
|
||||
_defaults = {
|
||||
'photo' : _default_photo,
|
||||
}
|
||||
|
||||
pos_category()
|
||||
|
||||
import io, StringIO
|
||||
|
|
|
@ -648,6 +648,9 @@
|
|||
<field name="parent_id"/>
|
||||
<field name="sequence"/>
|
||||
</group>
|
||||
<group colspan="2" col="1">
|
||||
<field name="photo" widget='image' nolabel="1" on_change="onchange_photo(photo)"/>
|
||||
</group>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
@ -765,6 +768,7 @@
|
|||
<field name="shop_id" widget="selection" />
|
||||
<field name="journal_id" widget="selection" />
|
||||
<field name="sequence_id" readonly="1"/>
|
||||
<field name="group_by" />
|
||||
<separator string="Available Payment Methods" colspan="4"/>
|
||||
<field name="journal_ids" colspan="4" nolabel="1">
|
||||
<tree string="Journals">
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from tools.translate import _
|
||||
from osv import osv, fields
|
||||
from account.wizard.pos_box import CashBox
|
||||
|
||||
|
@ -14,7 +16,14 @@ class PosBox(CashBox):
|
|||
|
||||
if active_model == 'pos.session':
|
||||
records = self.pool.get(active_model).browse(cr, uid, context.get('active_ids', []) or [], context=context)
|
||||
return self._run(cr, uid, ids, [record.cash_register_id for record in records], context=context)
|
||||
|
||||
bank_statements = [record.cash_register_id for record in records if record.cash_register_id]
|
||||
|
||||
if not bank_statements:
|
||||
raise osv.except_osv(_('Error !'),
|
||||
_("There is no cash register for this PoS Session"))
|
||||
|
||||
return self._run(cr, uid, ids, bank_statements, context=context)
|
||||
else:
|
||||
return super(PosBox, self).run(cr, uid, ids, context=context)
|
||||
|
||||
|
|
|
@ -70,7 +70,8 @@ class pos_make_payment(osv.osv_memory):
|
|||
if order_obj.test_paid(cr, uid, [active_id]):
|
||||
wf_service = netsvc.LocalService("workflow")
|
||||
wf_service.trg_validate(uid, 'pos.order', active_id, 'paid', cr)
|
||||
return self.print_report(cr, uid, ids, context=context)
|
||||
return {'type' : 'ir.actions.act_window_close' }
|
||||
##self.print_report(cr, uid, ids, context=context)
|
||||
|
||||
return self.launch_payment(cr, uid, ids, context=context)
|
||||
|
||||
|
|
|
@ -1,32 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
<data>
|
||||
<!-- Pos Receipt -->
|
||||
<record id="view_pos_receipt" model="ir.ui.view">
|
||||
<field name="name">Receipt</field>
|
||||
<field name="model">pos.receipt</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Receipt :">
|
||||
<separator string="Print the Receipt of the Sale" colspan="4"/>
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="print_report" string="Print Receipt"
|
||||
colspan="1" type="object" icon="gtk-print" />
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Pos Receipt -->
|
||||
|
||||
<record id="view_pos_receipt" model="ir.ui.view">
|
||||
<field name="name">Receipt</field>
|
||||
<field name="model">pos.receipt</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Receipt :">
|
||||
<separator string="Print the Receipt of the Sale" colspan="4"/>
|
||||
<button icon='gtk-cancel' special="cancel"
|
||||
string="Cancel" />
|
||||
<button name="print_report" string="Print Receipt"
|
||||
colspan="1" type="object" icon="gtk-print" />
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
<record id="action_report_pos_receipt" model="ir.actions.act_window">
|
||||
<record id="action_report_pos_receipt" model="ir.actions.act_window">
|
||||
<field name="name">Receipt</field>
|
||||
<field name="res_model">pos.receipt</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
Loading…
Reference in New Issue