[IMP] point_of_sales: Add the POS Session
bzr revid: stw@openerp.com-20120410112429-dckcpq3hfemlnr5n
This commit is contained in:
parent
bc05498416
commit
cd7d047cf8
|
@ -2617,7 +2617,7 @@ action = pool.get('res.config').next(cr, uid, [], context)
|
||||||
<group col="6" colspan="4">
|
<group col="6" colspan="4">
|
||||||
<field name="name" select="1"/>
|
<field name="name" select="1"/>
|
||||||
<field name='company_id' widget="selection" groups="base.group_multi_company" />
|
<field name='company_id' widget="selection" groups="base.group_multi_company" />
|
||||||
<field name="journal_id" on_change="onchange_journal_id(journal_id)" select="1" widget="selection"/>
|
<field name="journal_id" on_change="onchange_journal_id(journal_id)" select="1" widget="selection" domain="[('type', '=', 'cash')]"/>
|
||||||
<field name="user_id" select="1" readonly="1"/>
|
<field name="user_id" select="1" readonly="1"/>
|
||||||
<field name="period_id" select="1"/>
|
<field name="period_id" select="1"/>
|
||||||
<field name="currency" invisible="1"/>
|
<field name="currency" invisible="1"/>
|
||||||
|
|
|
@ -61,6 +61,9 @@ class pos_config(osv.osv):
|
||||||
|
|
||||||
'state' : fields.selection(POS_CONFIG_STATE, 'State', required=True, readonly=True),
|
'state' : fields.selection(POS_CONFIG_STATE, 'State', required=True, readonly=True),
|
||||||
|
|
||||||
|
#'sequence_id' : fields.many2one('ir.sequence', 'Sequence'),
|
||||||
|
# Add a sequence when we create a new pos.config object
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_defaults = {
|
_defaults = {
|
||||||
|
@ -84,10 +87,45 @@ pos_config()
|
||||||
class pos_session(osv.osv):
|
class pos_session(osv.osv):
|
||||||
_name = 'pos.session'
|
_name = 'pos.session'
|
||||||
|
|
||||||
|
POS_SESSION_STATE = [('new', 'New'),('opened', 'Opened'),('closed', 'Closed'),('posted', 'Posted')]
|
||||||
|
|
||||||
_columns = {
|
_columns = {
|
||||||
'config_id' : fields.many2one('pos.config', 'Configuration', required=True, select=1),
|
'config_id' : fields.many2one('pos.config', 'PoS', required=True, select=1),
|
||||||
|
|
||||||
|
'name' : fields.char('Session Sequence', size=32, required=True, select=1, readonly=1),
|
||||||
|
'user_id' : fields.many2one('res.users', 'User', required=True, select=1),
|
||||||
|
'start_at' : fields.datetime('Opening Date'), #, readonly=True),
|
||||||
|
'stop_at' : fields.datetime('Closing Date'),
|
||||||
|
|
||||||
|
'state' : fields.selection(POS_SESSION_STATE, 'State', required=True, readonly=True, select=1),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_defaults = {
|
||||||
|
'name' : '/',
|
||||||
|
'user_id' : lambda obj, cr, uid, context: uid,
|
||||||
|
'state' : 'new',
|
||||||
|
}
|
||||||
|
|
||||||
|
def create(self, cr, uid, values, context=None):
|
||||||
|
if values.pop('name', '/') == '/':
|
||||||
|
values['name'] = self.pool.get('ir.sequence').get(cr, uid, 'pos.session')
|
||||||
|
|
||||||
|
return super(pos_session, self).create(cr, uid, values, context=context)
|
||||||
|
|
||||||
|
def wkf_action_open(self, cr, uid, ids, context=None):
|
||||||
|
# si pas de date start_at, je balance une date, sinon on utilise celle de l'utilisateur
|
||||||
|
values = {
|
||||||
|
#'start_at' : time.strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
|
'state' : 'opened',
|
||||||
|
}
|
||||||
|
return self.write(cr, uid, ids, values, context=context)
|
||||||
|
|
||||||
|
def wkf_action_close(self, cr, uid, ids, context=None):
|
||||||
|
return self.write(cr, uid, ids, {'state' : 'close'}, context=context)
|
||||||
|
|
||||||
|
def wkf_action_post(self, cr, uid, ids, context=None):
|
||||||
|
return self.write(cr, uid, ids, {'state' : 'post'}, context=context)
|
||||||
|
|
||||||
pos_session()
|
pos_session()
|
||||||
|
|
||||||
class pos_config_journal(osv.osv):
|
class pos_config_journal(osv.osv):
|
||||||
|
@ -204,6 +242,8 @@ class pos_order(osv.osv):
|
||||||
'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', required=True, states={'draft': [('readonly', False)]}, readonly=True),
|
'pricelist_id': fields.many2one('product.pricelist', 'Pricelist', required=True, states={'draft': [('readonly', False)]}, readonly=True),
|
||||||
'partner_id': fields.many2one('res.partner', 'Customer', change_default=True, select=1, states={'draft': [('readonly', False)], 'paid': [('readonly', False)]}),
|
'partner_id': fields.many2one('res.partner', 'Customer', change_default=True, select=1, states={'draft': [('readonly', False)], 'paid': [('readonly', False)]}),
|
||||||
|
|
||||||
|
'session_id' : fields.many2one('pos.session', 'Session', required=True, select=1),
|
||||||
|
|
||||||
'state': fields.selection([('draft', 'New'),
|
'state': fields.selection([('draft', 'New'),
|
||||||
('cancel', 'Cancelled'),
|
('cancel', 'Cancelled'),
|
||||||
('paid', 'Paid'),
|
('paid', 'Paid'),
|
||||||
|
|
|
@ -28,5 +28,17 @@
|
||||||
<field name="padding">4</field>
|
<field name="padding">4</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.sequence.type" id="seq_type_pos_session">
|
||||||
|
<field name="name">POS Session</field>
|
||||||
|
<field name="code">pos.session</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.sequence" id="seq_pos_session">
|
||||||
|
<field name="name">POS Session</field>
|
||||||
|
<field name="code">pos.session</field>
|
||||||
|
<field name="prefix">POS/%(day)s/(month)s/%(year)s/</field>
|
||||||
|
<field name="padding">4</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|
|
@ -807,8 +807,8 @@
|
||||||
<field name="journal_id" widget="selection" />
|
<field name="journal_id" widget="selection" />
|
||||||
|
|
||||||
<separator string="Cash Differences" colspan="4" />
|
<separator string="Cash Differences" colspan="4" />
|
||||||
<field name="profit_account_id" widget="selection" />
|
<field name="profit_account_id" />
|
||||||
<field name="loss_account_id" widget="selection" />
|
<field name="loss_account_id" />
|
||||||
<field name="authorized_cashbox_diff" />
|
<field name="authorized_cashbox_diff" />
|
||||||
<field name="authorized_cashbox_diff_fixed" />
|
<field name="authorized_cashbox_diff_fixed" />
|
||||||
|
|
||||||
|
@ -828,7 +828,7 @@
|
||||||
</notebook>
|
</notebook>
|
||||||
|
|
||||||
<group colspan="4" col="6">
|
<group colspan="4" col="6">
|
||||||
<field name="state" />
|
<field name="state" widget="statusbar" statusbar_visible="draft,active,inactive,deprecated" statusbar_colors='{"active":"green", "deprecated" : "red"}'/>
|
||||||
<button string="Set to Draft" name="set_draft" type="object" states="deprecated"/>
|
<button string="Set to Draft" name="set_draft" type="object" states="deprecated"/>
|
||||||
<button string="Set to Active" name="set_active" type="object" states="draft,inactive"/>
|
<button string="Set to Active" name="set_active" type="object" states="draft,inactive"/>
|
||||||
<button string="Set to Inactive" name="set_inactive" type="object" states="active" />
|
<button string="Set to Inactive" name="set_inactive" type="object" states="active" />
|
||||||
|
@ -850,6 +850,13 @@
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
<act_window
|
||||||
|
id="act_pos_config_sessions"
|
||||||
|
name="Sessions"
|
||||||
|
src_model="pos.config"
|
||||||
|
res_model="pos.session"
|
||||||
|
domain="[('config_id', '=', active_id)]" />
|
||||||
|
|
||||||
<record model="ir.actions.act_window" id="action_pos_config_pos">
|
<record model="ir.actions.act_window" id="action_pos_config_pos">
|
||||||
<field name="name">Point of Sales</field>
|
<field name="name">Point of Sales</field>
|
||||||
<field name="type">ir.actions.act_window</field>
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
@ -865,6 +872,132 @@
|
||||||
groups="group_pos_manager"/>
|
groups="group_pos_manager"/>
|
||||||
|
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="view_pos_session_form">
|
||||||
|
<field name="name">pos.session.form.view</field>
|
||||||
|
<field name="model">pos.session</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form string="PoS Session">
|
||||||
|
<group colspan="4" col="6">
|
||||||
|
<field name="config_id" />
|
||||||
|
<field name="name" />
|
||||||
|
<field name="user_id" />
|
||||||
|
<field name="start_at" />
|
||||||
|
<field name="stop_at" />
|
||||||
|
</group>
|
||||||
|
<notebook colspan="4">
|
||||||
|
<page string="Cash">
|
||||||
|
</page>
|
||||||
|
<page string="Others">
|
||||||
|
</page>
|
||||||
|
<page string="Nothing">
|
||||||
|
</page>
|
||||||
|
</notebook>
|
||||||
|
|
||||||
|
<group colspan="4" col="2">
|
||||||
|
<field name="state" widget="statusbar" statusbar_visible="new,opened,closed,posted" statusbar_colors='{"posted":"green"}'/>
|
||||||
|
<button name="open" type="workflow" string="Open" states="new" />
|
||||||
|
<button name="close" type="workflow" string="Close" states="opened" />
|
||||||
|
<button name="post" type="workflow" string="Post" states="closed" />
|
||||||
|
</group>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="view_pos_session_tree">
|
||||||
|
<field name="name">pos.session.tree.view</field>
|
||||||
|
<field name="model">pos.session</field>
|
||||||
|
<field name="type">tree</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree string="PoS Session">
|
||||||
|
<field name="config_id" />
|
||||||
|
<field name="name" />
|
||||||
|
<field name="user_id" />
|
||||||
|
<field name="start_at" />
|
||||||
|
<field name="stop_at" />
|
||||||
|
</tree>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<act_window
|
||||||
|
id="act_pos_session_orders"
|
||||||
|
name="Orders"
|
||||||
|
src_model="pos.session"
|
||||||
|
res_model="pos.order"
|
||||||
|
domain="[('session_id', '=', active_id)]" />
|
||||||
|
|
||||||
|
|
||||||
|
<record id="view_pos_order_filter" model="ir.ui.view">
|
||||||
|
<field name="name">pos.order.list.select</field>
|
||||||
|
<field name="model">pos.order</field>
|
||||||
|
<field name="type">search</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<search string="Search Sales Order">
|
||||||
|
<filter icon="terp-document-new" string="New" domain="[('state','=','draft')]"/>
|
||||||
|
<filter icon="gtk-apply" string="Done" domain="[('state','in',('paid','invoiced','done'))]"/>
|
||||||
|
<separator orientation="vertical"/>
|
||||||
|
<filter icon="terp-check" string="Invoiced" domain="[('state','=','invoiced')]"/>
|
||||||
|
<filter icon="gtk-convert" string="Posted" domain="[('state','=','done')]"/>
|
||||||
|
<separator orientation="vertical"/>
|
||||||
|
<filter icon="terp-go-month" string="Today" domain="[('date_order','>=',datetime.date.today().strftime('%%Y-%%m-%%d 00:00:00')),('date_order','<=',datetime.date.today().strftime('%%Y-%%m-%%d 23:59:59'))]"/>
|
||||||
|
<filter icon="gtk-go-forward" string="Yesterday" domain="[('date_order','<',datetime.date.today().strftime('%%Y-%%m-%%d 00:00:00')),('date_order','>=',(datetime.date.today() - relativedelta(days=1)).strftime('%%Y-%%m-%%d 00:00:00'))]"/>
|
||||||
|
<separator orientation="vertical"/>
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="user_id"/>
|
||||||
|
<newline/>
|
||||||
|
<group expand="0" string="Group By..." groups="base.group_extended">
|
||||||
|
<filter string="Customer" icon="terp-personal" domain="[]" context="{'group_by':'partner_id'}"/>
|
||||||
|
<filter string="Salesman" icon="terp-personal" domain="[]" context="{'group_by':'user_id'}"/>
|
||||||
|
<separator string="" orientation="vertical"/>
|
||||||
|
<filter string="State" icon="terp-stock_effects-object-colorize" domain="[]" context="{'group_by':'state'}"/>
|
||||||
|
<separator string="" orientation="vertical"/>
|
||||||
|
<filter string="Order Date" icon="terp-go-month" domain="[]" context="{'group_by':'date_order'}"/>
|
||||||
|
</group>
|
||||||
|
</search>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<record model="ir.ui.view" id="view_pos_session_search">
|
||||||
|
<field name="name">pos.session.search.view</field>
|
||||||
|
<field name="model">pos.session</field>
|
||||||
|
<field name="type">search</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<search string="PoS Session">
|
||||||
|
<filter string="Open" domain="[('state', '=', 'opened')]" />
|
||||||
|
<separator orientation="vertical"/>
|
||||||
|
<filter string="Today" domain="[('start_at', '>=', time.strftime('%%Y-%%m-%%d 00:00:00'))]" />
|
||||||
|
<separator orientation="vertical"/>
|
||||||
|
<field name="config_id" />
|
||||||
|
<field name="name" />
|
||||||
|
<field name="user_id" />
|
||||||
|
|
||||||
|
<newline />
|
||||||
|
<group expand="0" string="Group By...">
|
||||||
|
<filter string="User" icon="terp-personal" domain="[]" context="{'group_by' : 'user_id'}" />
|
||||||
|
<filter string="PoS" domain="[]" context="{'group_by': 'user_id'}" />
|
||||||
|
</group>
|
||||||
|
</search>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
|
||||||
|
<record model="ir.actions.act_window" id="action_pos_session">
|
||||||
|
<field name="name">Point of Sales Session</field>
|
||||||
|
<field name="type">ir.actions.act_window</field>
|
||||||
|
<field name="res_model">pos.session</field>
|
||||||
|
<field name="view_type">form</field>
|
||||||
|
<field name="view_mode">tree,form</field>
|
||||||
|
<!--
|
||||||
|
<field name="search_view_id" ref="view_pos_session_search" />
|
||||||
|
-->
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
parent="menu_point_of_sale"
|
||||||
|
action="action_pos_session"
|
||||||
|
id="menu_pos_session"
|
||||||
|
groups="group_pos_manager"/>
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|
|
@ -76,4 +76,56 @@
|
||||||
|
|
||||||
|
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
|
<data>
|
||||||
|
<record model="workflow" id="wkf_pos_session">
|
||||||
|
<field name="name">POS Session Workflow</field>
|
||||||
|
<field name="osv">pos.session</field>
|
||||||
|
<field name="on_create">True</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- Activities -->
|
||||||
|
|
||||||
|
<record model="workflow.activity" id="act_new">
|
||||||
|
<field name="wkf_id" ref="wkf_pos_session"/>
|
||||||
|
<field name="flow_start">True</field>
|
||||||
|
<field name="name">new</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="workflow.activity" id="act_open">
|
||||||
|
<field name="wkf_id" ref="wkf_pos_session"/>
|
||||||
|
<field name="name">open</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="workflow.activity" id="act_close">
|
||||||
|
<field name="wkf_id" ref="wkf_pos_session"/>
|
||||||
|
<field name="name">close</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="workflow.activity" id="act_post">
|
||||||
|
<field name="wkf_id" ref="wkf_pos_session"/>
|
||||||
|
<field name="flow_stop">True</field>
|
||||||
|
<field name="name">post</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<!-- Transitions -->
|
||||||
|
<record model="workflow.transition" id="trans_new_open">
|
||||||
|
<field name="act_from" ref="act_new"/>
|
||||||
|
<field name="act_to" ref="act_open"/>
|
||||||
|
<field name="signal">open</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="workflow.transition" id="trans_open_close">
|
||||||
|
<field name="act_from" ref="act_open"/>
|
||||||
|
<field name="act_to" ref="act_close"/>
|
||||||
|
<field name="signal">close</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="workflow.transition" id="trans_close_post">
|
||||||
|
<field name="act_from" ref="act_close"/>
|
||||||
|
<field name="act_to" ref="act_post"/>
|
||||||
|
<field name="signal">post</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</data>
|
||||||
</openerp>
|
</openerp>
|
||||||
|
|
|
@ -73,10 +73,13 @@ class pos_box_entries(osv.osv_memory):
|
||||||
'product_id': fields.selection(_get_income_product, "Operation", required=True, size=-1),
|
'product_id': fields.selection(_get_income_product, "Operation", required=True, size=-1),
|
||||||
'amount': fields.float('Amount', digits=(16, 2), required=True),
|
'amount': fields.float('Amount', digits=(16, 2), required=True),
|
||||||
'ref': fields.char('Ref', size=32),
|
'ref': fields.char('Ref', size=32),
|
||||||
|
'session_id' : fields.many2one('pos.session', 'Session'),
|
||||||
|
'user_id' : fields.many2one('res.users', 'User'),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'journal_id': 1,
|
'journal_id': 1,
|
||||||
'product_id': 1,
|
'product_id': 1,
|
||||||
|
'user_id' : lambda obj, cr, uid, context: uid,
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_in(self, cr, uid, ids, context=None):
|
def get_in(self, cr, uid, ids, context=None):
|
||||||
|
|
|
@ -10,10 +10,12 @@
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Put Money">
|
<form string="Put Money">
|
||||||
<separator string="Fill in this form if you put money in the cash register:" colspan="4"/>
|
<separator string="Fill in this form if you put money in the cash register:" colspan="4"/>
|
||||||
<field name="name"/>
|
|
||||||
<field name="product_id"/>
|
|
||||||
<field name="journal_id"/>
|
<field name="journal_id"/>
|
||||||
|
<field name="product_id"/>
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
|
<field name="session_id" />
|
||||||
|
<field name="user_id" invisible="1" />
|
||||||
|
<field name="name"/>
|
||||||
<separator colspan="4"/>
|
<separator colspan="4"/>
|
||||||
<group colspan="4" col="4">
|
<group colspan="4" col="4">
|
||||||
<group col="2" colspan="2"/>
|
<group col="2" colspan="2"/>
|
||||||
|
|
|
@ -52,10 +52,13 @@ class pos_box_out(osv.osv_memory):
|
||||||
'journal_id': fields.selection(pos_box_entries.get_journal, "Cash Register", required=True, size=-1),
|
'journal_id': fields.selection(pos_box_entries.get_journal, "Cash Register", required=True, size=-1),
|
||||||
'product_id': fields.selection(_get_expense_product, "Operation", required=True, size=-1),
|
'product_id': fields.selection(_get_expense_product, "Operation", required=True, size=-1),
|
||||||
'amount': fields.float('Amount', digits=(16, 2), required=True),
|
'amount': fields.float('Amount', digits=(16, 2), required=True),
|
||||||
|
'session_id' : fields.many2one('pos.session', 'Session'),
|
||||||
|
'user_id' : fields.many2one('res.users', 'User'),
|
||||||
}
|
}
|
||||||
_defaults = {
|
_defaults = {
|
||||||
'journal_id': 1,
|
'journal_id': 1,
|
||||||
'product_id': 1,
|
'product_id': 1,
|
||||||
|
'user_id' : lambda obj, cr, uid, context: uid,
|
||||||
}
|
}
|
||||||
def get_out(self, cr, uid, ids, context=None):
|
def get_out(self, cr, uid, ids, context=None):
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,12 @@
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form string="Output Operation">
|
<form string="Output Operation">
|
||||||
<separator string="Describe why you take money from the cash register:" colspan="4"/>
|
<separator string="Describe why you take money from the cash register:" colspan="4"/>
|
||||||
<field name="name"/>
|
|
||||||
<field name="product_id"/>
|
|
||||||
<field name="journal_id"/>
|
<field name="journal_id"/>
|
||||||
|
<field name="product_id"/>
|
||||||
<field name="amount"/>
|
<field name="amount"/>
|
||||||
|
<field name="session_id" />
|
||||||
|
<field name="name"/>
|
||||||
|
<field name="user_id" invisible="1" />
|
||||||
<separator colspan="4"/>
|
<separator colspan="4"/>
|
||||||
<group colspan="4" col="4">
|
<group colspan="4" col="4">
|
||||||
<group col="2" colspan="2"/>
|
<group col="2" colspan="2"/>
|
||||||
|
|
Loading…
Reference in New Issue