diff --git a/customer_sequence/README.rst b/customer_sequence/README.rst new file mode 100644 index 000000000..0a986fcce --- /dev/null +++ b/customer_sequence/README.rst @@ -0,0 +1,24 @@ +Customer Sequence v10 +===================== + +This module will give a unique code to each customer and supplier. + + + +Configuration +============= +You should configure the company form for the proper working of this module. +The supplier code will start from 0000,0001,.. and customer code start from the number you give in the company form + +Further information +=================== +I added a security file which gives access res.company for all users. +if you not configure the company form then the customer code start with 1,2,..and supplier code always start with 0001,0002,.. + +Credits +======= +Cybrosys Techno Solutions + +Author +====== +* Cybrosys Techno Solutions diff --git a/customer_sequence/__init__.py b/customer_sequence/__init__.py new file mode 100644 index 000000000..89d26e2f5 --- /dev/null +++ b/customer_sequence/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: utf-8 -*- +import models diff --git a/customer_sequence/__manifest__.py b/customer_sequence/__manifest__.py new file mode 100644 index 000000000..659f47e4d --- /dev/null +++ b/customer_sequence/__manifest__.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +{ + 'name': "Customer Sequence", + 'version': '10.0.1.0.0', + 'summary': """Unique Customer Code""", + 'description': """ + Each customer have unique number code + """, + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': "https://cybrosys.com/", + 'category': 'Sales', + 'depends': ['sale'], + 'data': [ + 'views/res_partner_fom.xml', + 'views/res_company.xml', + 'security/ir.model.access.csv', + ], + 'demo': [], + 'images': ['static/description/banner.jpg'], + 'license': 'LGPL-3', + 'installable': True, + 'application': False +} diff --git a/customer_sequence/models/__init__.py b/customer_sequence/models/__init__.py new file mode 100644 index 000000000..469b442d8 --- /dev/null +++ b/customer_sequence/models/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- +import res_company +import res_partner diff --git a/customer_sequence/models/res_company.py b/customer_sequence/models/res_company.py new file mode 100644 index 000000000..69d182995 --- /dev/null +++ b/customer_sequence/models/res_company.py @@ -0,0 +1,10 @@ +# -*- coding: utf-8 -*- +from odoo import models, fields + + +class CompanySequence(models.Model): + _inherit = 'res.company' + + customer_code = fields.Integer(string='Customer code', required=True) + supp_code = fields.Integer(string='Supplier code') + next_code = fields.Integer(string='Next code') diff --git a/customer_sequence/models/res_partner.py b/customer_sequence/models/res_partner.py new file mode 100644 index 000000000..b402ef841 --- /dev/null +++ b/customer_sequence/models/res_partner.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +from odoo import models, fields, api + + +class ResPartner(models.Model): + _inherit = 'res.partner' + + unique_id = fields.Char(string='Unique Id', help="The Unique Sequence no", readonly=True, default='/') + + @api.model + def create(self, values): + res = super(ResPartner, self).create(values) + company_seq = self.env['res.users'].browse(self._uid).company_id + + if res.customer == True and res.unique_id == '/': + if company_seq.next_code: + res.unique_id = company_seq.next_code + res.name = '[' + str(company_seq.next_code) + ']' + str(res.name) + company_seq.write({'next_code': company_seq.next_code + 1}) + else: + res.unique_id = company_seq.customer_code + res.name = '[' + str(company_seq.customer_code) + ']' + str(res.name) + company_seq.write({'next_code': company_seq.customer_code + 1}) + if res.supplier == True and res.unique_id == '/': + if company_seq.supp_code < 10: + res.unique_id = '000' + str(company_seq.supp_code) + res.name = '[' + '000' + str(company_seq.supp_code) + ']' + str(res.name) + company_seq.write({'supp_code': company_seq.supp_code + 1}) + elif company_seq.supp_code < 100: + res.unique_id = '00' + str(company_seq.supp_code) + res.name = '[' + '00' + str(company_seq.supp_code) + ']' + str(res.name) + company_seq.write({'supp_code': company_seq.supp_code + 1}) + elif company_seq.supp_code < 1000: + res.unique_id = '0' + str(company_seq.supp_code) + res.name = '[' + '0' + str(company_seq.supp_code) + ']' + str(res.name) + company_seq.write({'supp_code': company_seq.supp_code + 1}) + elif company_seq.supp_code > 1000: + res.unique_id = company_seq.supp_code + res.name = '[' + str(company_seq.supp_code) + ']' + str(res.name) + company_seq.write({'supp_code': company_seq.supp_code + 1}) + else: + res.unique_id = company_seq.supp_code + res.name = '[' + '0001' + ']' + str(res.name) + company_seq.write({'supp_code': 2}) + return res diff --git a/customer_sequence/security/ir.model.access.csv b/customer_sequence/security/ir.model.access.csv new file mode 100644 index 000000000..259c9de31 --- /dev/null +++ b/customer_sequence/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink + +access_res_company,access_res_company,model_res_company,base.group_user,1,1,1,0 diff --git a/customer_sequence/static/description/banner.jpg b/customer_sequence/static/description/banner.jpg new file mode 100644 index 000000000..7451342d6 Binary files /dev/null and b/customer_sequence/static/description/banner.jpg differ diff --git a/customer_sequence/static/description/company_form.png b/customer_sequence/static/description/company_form.png new file mode 100644 index 000000000..0fed569a8 Binary files /dev/null and b/customer_sequence/static/description/company_form.png differ diff --git a/customer_sequence/static/description/customer_form.png b/customer_sequence/static/description/customer_form.png new file mode 100644 index 000000000..96871c188 Binary files /dev/null and b/customer_sequence/static/description/customer_form.png differ diff --git a/customer_sequence/static/description/cybro_logo.png b/customer_sequence/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/customer_sequence/static/description/cybro_logo.png differ diff --git a/customer_sequence/static/description/icon.png b/customer_sequence/static/description/icon.png new file mode 100644 index 000000000..71a3a3528 Binary files /dev/null and b/customer_sequence/static/description/icon.png differ diff --git a/customer_sequence/static/description/index.html b/customer_sequence/static/description/index.html new file mode 100644 index 000000000..4cc9d1a5a --- /dev/null +++ b/customer_sequence/static/description/index.html @@ -0,0 +1,72 @@ +
+
+

Customer Sequence

+

Give unique code to each customer

+

Cybrosys Technologies

+
+
+ +
+
+
+

Overview

+

+ Now it is very easy to identify your customers with unique code. This module gives coding to the customers as well as to the supplier. +

+
+
+
+
+
+

Company form

+
+

+ ☛ Give the starting number of code.
+ ☛ You can give separate starting for each company if it is a multi company.
+

+
+ +
+
+
+
+
+
+

Customer Form

+
+

+ ☛ Create a customer and the code will generate automatically as defined in the company form..
+

+
+ +
+
+
+
+ +
+

Need Any Help?

+ +
+ diff --git a/customer_sequence/views/res_company.xml b/customer_sequence/views/res_company.xml new file mode 100644 index 000000000..72724c4a8 --- /dev/null +++ b/customer_sequence/views/res_company.xml @@ -0,0 +1,16 @@ + + + + + Company Sequence + res.company + + + + + + + + + + diff --git a/customer_sequence/views/res_partner_fom.xml b/customer_sequence/views/res_partner_fom.xml new file mode 100644 index 000000000..dcb8d32ef --- /dev/null +++ b/customer_sequence/views/res_partner_fom.xml @@ -0,0 +1,26 @@ + + + + + res.partner.form.inherit + res.partner + + + + + + + + + + res.partner.form.inherit + res.partner + + + + + + + + + \ No newline at end of file