<commit_before>##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
##############################################################################

import wizard
import datetime
import pooler

_followup_wizard_all_form = """<?xml version="1.0"?>
<form string="Select partners" colspan="4">
	<notebook>
	<page string="FollowUp selection">
		<separator string="Select partners to remind" colspan="4"/>
		<field name="partner_ids" colspan="4" nolabel="1"/>
	</page><page string="Email confirmation">
		<label string="Not yet implemented !" colspan="4"/>
		<field name="email_conf" colspan="4"/>
		<separator string="Email body" colspan="4"/>
		<field name="email_body" colspan="4" nolabel="1"/>
		<separator string="Legend" colspan="4"/>

		<label string="%(partner_name)s: Partner name" colspan="2"/>
		<label string="%(user_signature)s: Partner name" colspan="2"/>
		<label string="%(followup_level)s: Followup level" colspan="2"/>
		<label string="%(followup_amount)s: Followup level" colspan="2"/>
		<label string="%(followup_details)s: Followup level" colspan="2"/>
	</page>
	</notebook>
</form>"""

_followup_wizard_all_fields = {
	'partner_ids': {
		'string': "Partners", 
		'type': 'many2many', 
		'relation': 'account_followup.stat',
	},
	'email_conf': {
		'string': "Send email confirmation", 
		'type': 'boolean', 
	},
	'email_body': {
		'string': "Email body", 
		'type': 'text', 
		'default': '''
Dear %(partner_name)s,

Please find in attachment our reminder for a total amount due
of %(followup_amount).2f EUR.

The details is here:
%(followup_details)s

%(followup_level)s
Thanks,

-- 
%(user_signature)s
		'''
	}
}


class followup_all_print(wizard.interface):
	def _get_partners(self, cr, uid, data, context):
		cr.execute(
			"SELECT distinct l.partner_id "\
			"FROM account_move_line AS l LEFT JOIN account_account AS a "\
				"ON (l.account_id=a.id) "\
			"WHERE (l.reconcile_id IS NULL) "\
				"AND (a.type='receivable') "\
				"AND (l.state<>'draft') "\
				"AND (l.reconcile_id is NULL) ")
		ids = map(lambda x: x[0], cr.fetchall())
		return {'partner_ids': ids}

	def _update_partners(self, cr, uid, data, context):
		partner_ids = data['form']['partner_ids'][0][2]
		if partner_ids:
			cr.execute(
				"SELECT l.partner_id, l.followup_line_id, l.date, l.id "\
				"FROM account_move_line AS l LEFT JOIN account_account AS a "\
					"ON (l.account_id=a.id) "\
				"WHERE (l.reconcile_id IS NULL) "\
					"AND (a.type='receivable') "\<commit_msg>account_followup: fix wizard for move line without partner<commit_after>##############################################################################
#
# Copyright (c) 2006 TINY SPRL. (http://tiny.be) All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
##############################################################################

import wizard
import datetime
import pooler

_followup_wizard_all_form = """<?xml version="1.0"?>
<form string="Select partners" colspan="4">
	<notebook>
	<page string="FollowUp selection">
		<separator string="Select partners to remind" colspan="4"/>
		<field name="partner_ids" colspan="4" nolabel="1"/>
	</page><page string="Email confirmation">
		<label string="Not yet implemented !" colspan="4"/>
		<field name="email_conf" colspan="4"/>
		<separator string="Email body" colspan="4"/>
		<field name="email_body" colspan="4" nolabel="1"/>
		<separator string="Legend" colspan="4"/>

		<label string="%(partner_name)s: Partner name" colspan="2"/>
		<label string="%(user_signature)s: Partner name" colspan="2"/>
		<label string="%(followup_level)s: Followup level" colspan="2"/>
		<label string="%(followup_amount)s: Followup level" colspan="2"/>
		<label string="%(followup_details)s: Followup level" colspan="2"/>
	</page>
	</notebook>
</form>"""

_followup_wizard_all_fields = {
	'partner_ids': {
		'string': "Partners", 
		'type': 'many2many', 
		'relation': 'account_followup.stat',
	},
	'email_conf': {
		'string': "Send email confirmation", 
		'type': 'boolean', 
	},
	'email_body': {
		'string': "Email body", 
		'type': 'text', 
		'default': '''
Dear %(partner_name)s,

Please find in attachment our reminder for a total amount due
of %(followup_amount).2f EUR.

The details is here:
%(followup_details)s

%(followup_level)s
Thanks,

-- 
%(user_signature)s
		'''
	}
}


class followup_all_print(wizard.interface):
	def _get_partners(self, cr, uid, data, context):
		cr.execute(
			"SELECT distinct l.partner_id "\
			"FROM account_move_line AS l LEFT JOIN account_account AS a "\
				"ON (l.account_id=a.id) "\
			"WHERE (l.reconcile_id IS NULL) "\
				"AND (a.type='receivable') "\
				"AND (l.state<>'draft') "\
				"AND (l.reconcile_id is NULL) "\
				"AND (l.partner_id is NOT NULL) ")
		ids = map(lambda x: x[0], cr.fetchall())
		return {'partner_ids': ids}

	def _update_partners(self, cr, uid, data, context):
		partner_ids = data['form']['partner_ids'][0][2]
		if partner_ids:
			cr.execute(
				"SELECT l.partner_id, l.followup_line_id, l.date, l.id "\
				"FROM account_move_line AS l LEFT JOIN account_account AS a "\
					"ON (l.account_id=a.id) "\
				"WHERE (l.reconcile_id IS NULL) "\
					"AND (a.type='receivable') "\
{'fraction_non_alphanumeric': 0.1708672086720867, 'fraction_numerical': 0.011111111111111112, 'mean_word_length': 4.757410296411856, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 2, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5392011', 'n_tokens_mistral': 2540, 'n_tokens_neox': 2271, 'n_words': 764}