1
0
Fork 0
This repository has been archived on 2022-08-09. You can view files and clone it, but cannot push or open issues or pull requests.
odoo-pos-distribution/odoo/addons/pos_product_sequence/models/product.py

25 lines
735 B
Python

# -*- coding: utf-8 -*-
from odoo import fields, models, api
class ProductProduct(models.Model):
_inherit = "product.product"
_order = 'pos_sequence, default_code, name, id'
class ProductTemplate(models.Model):
_inherit = "product.template"
_order = 'pos_sequence, name'
pos_sequence = fields.Integer(string='POS Sequence', help='POS product display base on product sequence number')
@api.model
def create(self, vals):
res = super(ProductTemplate, self).create(vals)
if res:
rec = self.search([])
if rec:
seq = max(self.search([]).mapped('pos_sequence'))
if seq:
res.pos_sequence = seq + 1;
return res