added new module dp_sequence_date_range_monthly, which allows it to have a number range monthly instead of yearly
							parent
							
								
									3d8176991f
								
							
						
					
					
						commit
						efbf71d577
					
				|  | @ -0,0 +1,24 @@ | |||
| # -*- coding: utf-8 -*- | ||||
| ############################################################################## | ||||
| # | ||||
| #    datenpol gmbh | ||||
| #    Copyright (C) 2013-TODAY datenpol gmbh (<http://www.datenpol.at/>) | ||||
| # | ||||
| #    This program is free software: you can redistribute it and/or modify | ||||
| #    it under the terms of the GNU Affero General Public License as | ||||
| #    published by the Free Software Foundation, either version 3 of the | ||||
| #    License, or (at your option) any later version. | ||||
| # | ||||
| #    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 Affero General Public License for more details. | ||||
| # | ||||
| #    You should have received a copy of the GNU Affero General Public License | ||||
| #    along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
| # | ||||
| ############################################################################## | ||||
| 
 | ||||
| import models | ||||
| 
 | ||||
| # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||||
|  | @ -0,0 +1,41 @@ | |||
| # -*- coding: utf-8 -*- | ||||
| ############################################################################## | ||||
| # | ||||
| #    datenpol gmbh | ||||
| #    Copyright (C) 2013-TODAY datenpol gmbh (<http://www.datenpol.at/>) | ||||
| # | ||||
| #    This program is free software: you can redistribute it and/or modify | ||||
| #    it under the terms of the GNU Affero General Public License as | ||||
| #    published by the Free Software Foundation, either version 3 of the | ||||
| #    License, or (at your option) any later version. | ||||
| # | ||||
| #    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 Affero General Public License for more details. | ||||
| # | ||||
| #    You should have received a copy of the GNU Affero General Public License | ||||
| #    along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
| # | ||||
| ############################################################################## | ||||
| 
 | ||||
| 
 | ||||
| # noinspection PyStatementEffect | ||||
| { | ||||
|     'name': 'datenpol Sequence date range monthly', | ||||
|     'category': 'Custom', | ||||
|     'version': '1.0', | ||||
|     'description': """Für jeden Monat gibt es eine eigenen Nummernkreis""", | ||||
|     'author': 'datenpol gmbh', | ||||
|     'website': 'http://www.datenpol.at/', | ||||
|     'depends': [ | ||||
|         'base', | ||||
|     ], | ||||
|     'data': [ | ||||
|         'views/ir_sequence_view.xml', | ||||
|     ], | ||||
|     'installable': True, | ||||
|     'auto_install': False, | ||||
| } | ||||
| 
 | ||||
| # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||||
|  | @ -0,0 +1,26 @@ | |||
| # -*- coding: utf-8 -*- | ||||
| ############################################################################## | ||||
| # | ||||
| #    OpenERP, Open Source Management Solution | ||||
| #    Copyright (C) 20014-2016 datenpol gmbh (<http://www.datenpol.at/>). | ||||
| # | ||||
| #    This program is free software: you can redistribute it and/or modify | ||||
| #    it under the terms of the GNU Affero General Public License as | ||||
| #    published by the Free Software Foundation, either version 3 of the | ||||
| #    License, or (at your option) any later version. | ||||
| # | ||||
| #    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 Affero General Public License for more details. | ||||
| # | ||||
| #    You should have received a copy of the GNU Affero General Public License | ||||
| #    along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
| # | ||||
| ############################################################################## | ||||
| 
 | ||||
| import ir_sequence | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | ||||
|  | @ -0,0 +1,60 @@ | |||
| # -*- coding: utf-8 -*- | ||||
| ############################################################################## | ||||
| # | ||||
| #    datenpol gmbh | ||||
| #    Copyright (C) 2013-TODAY datenpol gmbh (<http://www.datenpol.at/>) | ||||
| # | ||||
| #    This program is free software: you can redistribute it and/or modify | ||||
| #    it under the terms of the GNU Affero General Public License as | ||||
| #    published by the Free Software Foundation, either version 3 of the | ||||
| #    License, or (at your option) any later version. | ||||
| # | ||||
| #    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 Affero General Public License for more details. | ||||
| # | ||||
| #    You should have received a copy of the GNU Affero General Public License | ||||
| #    along with this program.  If not, see <http://www.gnu.org/licenses/>. | ||||
| # | ||||
| ############################################################################## | ||||
| 
 | ||||
| from odoo import api, fields, models | ||||
| from datetime import datetime, timedelta | ||||
| from dateutil.relativedelta import relativedelta | ||||
| 
 | ||||
| 
 | ||||
| class IrSequence(models.Model): | ||||
|     _inherit = 'ir.sequence' | ||||
| 
 | ||||
|     monthly_date_range = fields.Boolean('Monthly date_range') | ||||
| 
 | ||||
|     def _create_date_range_seq(self, date): | ||||
|         year = fields.Date.from_string(date).strftime('%Y') | ||||
|         if self.monthly_date_range: | ||||
|             month = fields.Date.from_string(date).strftime('%m') | ||||
|             last_day = datetime(int(year), int(month), 1) + relativedelta(day=31) | ||||
|             date_from = '{}-{}-01'.format(year, month) | ||||
|             date_to = '{}-{}-{}'.format(year, month, last_day.day) | ||||
|         else: | ||||
|             date_from = '{}-01-01'.format(year) | ||||
|             date_to = '{}-12-31'.format(year) | ||||
|         date_range = self.env['ir.sequence.date_range'].search \ | ||||
|             ([('sequence_id', '=', self.id), ('date_from', '>=', date), ('date_from', '<=', date_to)], | ||||
|              order='date_from desc', limit=1) | ||||
|         if date_range: | ||||
|             date_to = datetime.strptime(date_range.date_from, '%Y-%m-%d') + timedelta(days=-1) | ||||
|             date_to = date_to.strftime('%Y-%m-%d') | ||||
|         date_range = self.env['ir.sequence.date_range'].search \ | ||||
|             ([('sequence_id', '=', self.id), ('date_to', '>=', date_from), ('date_to', '<=', date)], | ||||
|              order='date_to desc', | ||||
|              limit=1) | ||||
|         if date_range: | ||||
|             date_from = datetime.strptime(date_range.date_to, '%Y-%m-%d') + timedelta(days=1) | ||||
|             date_from = date_from.strftime('%Y-%m-%d') | ||||
|         seq_date_range = self.env['ir.sequence.date_range'].sudo().create({ | ||||
|             'date_from': date_from, | ||||
|             'date_to': date_to, | ||||
|             'sequence_id': self.id, | ||||
|         }) | ||||
|         return seq_date_range | ||||
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 2.2 KiB | 
|  | @ -0,0 +1,18 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <odoo> | ||||
|     <data> | ||||
| 
 | ||||
|         <!-- IR_SEQUENCE - EXTENDED FORM --> | ||||
|         <record id="dp_ir_sequence_form" model="ir.ui.view"> | ||||
|             <field name="name">dp_ir_sequence_form</field> | ||||
|             <field name="model">ir.sequence</field> | ||||
|             <field name="inherit_id" ref="base.sequence_view"/> | ||||
|             <field name="arch" type="xml"> | ||||
|                 <field name="use_date_range" position="after"> | ||||
|                     <field name="monthly_date_range"/> | ||||
|                 </field> | ||||
|             </field> | ||||
|         </record> | ||||
| 
 | ||||
|     </data> | ||||
| </odoo> | ||||
|  | @ -141,13 +141,15 @@ class Config(): | |||
|                 # 'number_next_actual': 1, | ||||
|                 'prefix': '%(y)s', | ||||
|                 'padding': 4, | ||||
|                 'use_date_range': True | ||||
|                 'use_date_range': True, | ||||
|                 'monthly_date_range': False | ||||
|             }, | ||||
|             'account.invoice': { | ||||
|                 # 'number_next_actual': 0001, | ||||
|                 'prefix': '%(y)s%(month)s', | ||||
|                 'padding': 4, | ||||
|                 'use_date_range': True | ||||
|                 'use_date_range': True, | ||||
|                 'monthly_date_range': False | ||||
|             }, | ||||
|             # Wenn 'account.invoice_refund' auskommentiert ist, dann wird | ||||
|             # für die Gutschrift der selbe Nummernkreis verwendet | ||||
|  | @ -157,7 +159,8 @@ class Config(): | |||
|                 'implementation': 'no_gap', | ||||
|                 'prefix': '%(y)s', | ||||
|                 'padding': 4, | ||||
|                 'use_date_range': True | ||||
|                 'use_date_range': True, | ||||
|                 'monthly_date_range': False | ||||
|             }, | ||||
|             #'picking.out': { | ||||
|             #    # 'number_next_actual': 1, | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue