From c5b66229d8b1d4292d8a76a025ac7710d7deb251 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 11 May 2022 06:45:48 +0000 Subject: [PATCH] divers --- controllers/controllers.py | 10 ++++++ controllers/donation.py | 3 ++ i18n/fr.po | 6 ++++ models/donation.py | 2 ++ models/operation.py | 7 ++--- models/partner.py | 2 ++ static/src/js/opendons.js | 56 ++++++++++++++++++++++++++++++++++ static/src/js/payment_batch.js | 1 - views/donation.xml | 27 ++++++++++++++++ views/partner.xml | 9 +++++- views/payment_batch.xml | 9 ++---- 11 files changed, 119 insertions(+), 13 deletions(-) create mode 100644 static/src/js/opendons.js diff --git a/controllers/controllers.py b/controllers/controllers.py index d10702a..ee4ed69 100644 --- a/controllers/controllers.py +++ b/controllers/controllers.py @@ -1,11 +1,21 @@ # -*- coding: utf-8 -*- from odoo import http from odoo.http import request +import werkzeug from odoo.exceptions import UserError from odoo.addons.website_sale.controllers.main import WebsiteSale import json +class opendons(http.Controller): + @http.route(['/opendons/cp'],type='json', methods=['GET','POST'],auth="public",csrf=False) + def index(self, **post): + name = post.get('name', False) + res={} + res['dd']='ggggg' + json_object = json.dumps(res, indent = 4) + return json_object + class SalesProduct(WebsiteSale): @http.route(['/shop/cart/update'], type='http', auth="public", methods=['POST'], website=True) diff --git a/controllers/donation.py b/controllers/donation.py index d626de1..9f2e6eb 100644 --- a/controllers/donation.py +++ b/controllers/donation.py @@ -10,3 +10,6 @@ class donation(http.Controller): def make_donation(self, **kw): return http.request.render('opendons.makedonation_form') + + + diff --git a/i18n/fr.po b/i18n/fr.po index d58f0e8..cd51150 100644 --- a/i18n/fr.po +++ b/i18n/fr.po @@ -60,6 +60,12 @@ msgstr " de requêtes" msgid "# of segment" msgstr "" +#. module: opendons +#: code:addons/opendons/models/operation.py:0 +#, python-format +msgid "name already exist" +msgstr "ce nom existe déjà" + #. module: opendons #: model:ir.model.fields,field_description:opendons.field_opendons_operation__number_of_sending msgid "# of sending" diff --git a/models/donation.py b/models/donation.py index 0bf3b27..0af4c2e 100644 --- a/models/donation.py +++ b/models/donation.py @@ -10,6 +10,8 @@ import base64 class DonationDonation(models.Model): _inherit = 'donation.donation' + donor_id=fields.Char(related='partner_id.donor_id') + operation_id = fields.Many2one( 'opendons.operation', string='Operation', diff --git a/models/operation.py b/models/operation.py index 52c5332..63ed896 100644 --- a/models/operation.py +++ b/models/operation.py @@ -72,10 +72,7 @@ class opendons_operation(models.Model): ondelete='restrict', default=_default_currency ) - # _sql_constraints = [ - # ('name_uniq', 'unique (name)', "Name already exists !") - - # ] + number_of_sending = fields.Integer( compute='_compute_number_of_sending', @@ -266,7 +263,7 @@ class opendons_operation(models.Model): if "company_id" in vals: self = self.with_company(vals["company_id"]) - if op : raise Warning('name already exist') + if op : raise Warning(_('name already exist')) res=super(opendons_operation, self).create(vals) #création du segment d'exclusion diff --git a/models/partner.py b/models/partner.py index cec0495..95b3dd9 100644 --- a/models/partner.py +++ b/models/partner.py @@ -146,6 +146,8 @@ class partner(models.Model): donor_id=fields.Char('Donor id',compute="_compute_donor_id",store=True) + + def _compute_donor_id(self): for rec in self: if rec.key: diff --git a/static/src/js/opendons.js b/static/src/js/opendons.js new file mode 100644 index 0000000..a6a3c32 --- /dev/null +++ b/static/src/js/opendons.js @@ -0,0 +1,56 @@ +odoo.define('opendons.opendons', function (require) { + "use strict"; + + + + $("body").on("click","[name='zip']",function(ev){ + alert('toto'); + }); + // var rpc=require('web.rpc'); + // return { + // start: function (){ + // $('[name="zip"]').keydown(function(event) { + + // alert('toto'); + + // }); + // }, + + // } + + + + + // $(document).ready( function() + // { + + + + // // $.ajax({ + // // url: '/opendons/cp', + // // type: "POST", + // // data: fd, + // // dataType: 'json', + // // cache: false, + // // contentType: 'application/json; charset=utf-8', + // // processData: false, + // // success: function(data){ + // // console.log('Success! ' + data); + // // form.submit(); + // // }, + // // error: function(data){ + // // document.getElementById('form_error').innerHTML = "Stran je potrebno osvežit!"; + // // console.log(data); + // // } + + // }); + + + + + + + +}); + + diff --git a/static/src/js/payment_batch.js b/static/src/js/payment_batch.js index fbb818d..d4fd1a2 100644 --- a/static/src/js/payment_batch.js +++ b/static/src/js/payment_batch.js @@ -1,7 +1,6 @@ odoo.define('opendons.payment_batch', function (require) { "use strict"; - //opendons }); \ No newline at end of file diff --git a/views/donation.xml b/views/donation.xml index 686c128..8392baf 100644 --- a/views/donation.xml +++ b/views/donation.xml @@ -26,6 +26,33 @@ + + + opendons.donation.recurring.tree + donation.donation + + + + + + + + + + + opendons.donation.recurring.tree + donation.donation + + + + + + + + opendons.donation.recurring_generate.form donation.recurring.generate diff --git a/views/partner.xml b/views/partner.xml index 6e328e7..f4262d9 100644 --- a/views/partner.xml +++ b/views/partner.xml @@ -2,6 +2,13 @@ + + + Contacts ir.actions.act_window @@ -135,7 +142,7 @@ - + diff --git a/views/payment_batch.xml b/views/payment_batch.xml index 12f855f..70f0fe2 100644 --- a/views/payment_batch.xml +++ b/views/payment_batch.xml @@ -1,17 +1,14 @@ - + --> opendons_payment_batch list