[IMP] point_of_sale: make pos.config use active instead of custom state

pos.config had a special state field that mimiced what we usually do
with an 'active' field. The concepts of 'inactive' and 'deprecated' seem
to have never been fully worked out, as both of them resulted in the
same behaviour.
This commit is contained in:
Joren Van Onder
2016-04-20 15:46:04 +02:00
parent f1598883ab
commit bbaf956328
4 changed files with 5 additions and 33 deletions
+1 -19
View File
@@ -8,12 +8,6 @@ from odoo.exceptions import UserError
class PosConfig(models.Model):
_name = 'pos.config'
POS_CONFIG_STATE = [
('active', 'Active'),
('inactive', 'Inactive'),
('deprecated', 'Deprecated')
]
def _default_sale_journal(self):
return self.env['account.journal'].search([('type', '=', 'sale'), ('company_id', '=', self.env.user.company_id.id)], limit=1)
@@ -72,7 +66,7 @@ class PosConfig(models.Model):
receipt_footer = fields.Text(string='Receipt Footer', help="A short text that will be inserted as a footer in the printed receipt")
proxy_ip = fields.Char(string='IP Address', size=45,
help='The hostname or ip address of the hardware proxy, Will be autodetected if left empty')
state = fields.Selection(POS_CONFIG_STATE, string='Status', required=True, readonly=True, copy=False, default=POS_CONFIG_STATE[0][0])
active = fields.Boolean(default=True)
uuid = fields.Char(readonly=True, default=lambda self: str(uuid.uuid4()),
help='A globally unique identifier for this pos configuration, used to prevent conflicts in client-generated data')
sequence_id = fields.Many2one('ir.sequence', string='Order IDs Sequence', readonly=True,
@@ -198,18 +192,6 @@ class PosConfig(models.Model):
pos_config.sequence_id.unlink()
return super(PosConfig, self).unlink()
@api.multi
def set_active(self):
self.write({'state': 'active'})
@api.multi
def set_inactive(self):
self.write({'state': 'inactive'})
@api.multi
def set_deprecate(self):
self.write({'state': 'deprecated'})
# Methods to open the POS
@api.multi
def open_ui(self):
+1 -2
View File
@@ -29,8 +29,7 @@ class PosSession(models.Model):
'pos.config', string='Point of Sale',
help="The physical point of sale you will use.",
required=True,
index=True,
domain="[('state', '=', 'active')]")
index=True)
name = fields.Char(string='Session ID', required=True, readonly=True, default='/')
user_id = fields.Many2one(
'res.users', string='Responsible',
@@ -46,7 +46,6 @@
<field name="model">pos.config</field>
<field name="arch" type="xml">
<kanban create="false" class="o_kanban_dashboard o_pos_kanban">
<field name="state"/>
<field name="name"/>
<field name="session_ids"/>
<field name="current_session_id"/>
+3 -11
View File
@@ -5,13 +5,6 @@
<field name="model">pos.config</field>
<field name="arch" type="xml">
<form string="Point of Sale Configuration">
<header>
<button string="Set to Active" name="set_active" type="object" states="inactive,deprecated"/>
<button string="Set to Inactive" name="set_inactive" type="object" states="active" />
<button string="Set to Deprecated" name="set_deprecate" type="object" states="active,inactive" />
<field name="state" widget="statusbar" statusbar_visible="active,inactive,deprecated" statusbar_colors='{"deprecated" : "red"}' nolabel="1"/>
</header>
<sheet>
<label for="name" class="oe_edit_only"/>
<h1><field name="name"/></h1>
@@ -26,6 +19,7 @@
<field name="sequence_id" readonly="1" groups="base.group_no_one"/>
<field name="fiscal_position_ids" widget="many2many_tags" options="{'no_create': True}"/>
<field name="default_fiscal_position_id" options="{'no_create': True}"/>
<field name="active"/>
<field name="currency_id" invisible="1"/>
</group>
<separator string="Available Payment Methods" colspan="4"/>
@@ -74,10 +68,9 @@
<field name="name">pos.config.tree.view</field>
<field name="model">pos.config</field>
<field name="arch" type="xml">
<tree string="Point of Sale Configuration" decoration-muted="state == 'inactive'">
<tree string="Point of Sale Configuration">
<field name="name" />
<field name="stock_location_id" groups="stock.group_stock_multi_locations"/>
<field name="state" />
</tree>
</field>
</record>
@@ -88,8 +81,7 @@
<field name="arch" type="xml">
<search string="Point of Sale Config">
<field name="name" />
<filter string="Active" domain="[('state', '=', 'active')]" />
<filter string="Inactive" domain="[('state', '=', 'inactive')]" />
<filter string="Inactive" domain="[('active', '=', False)]" />
<field name="stock_location_id" groups="stock.group_stock_multi_locations" />
</search>
</field>