Set a category in tx_news by default - typo3-6.2.x

I would like to set a category by default to all new tx_news records. I know the solution is located in user TSConfig. But I don't know how to work with that using a kind of condition. I guess it has to be something like
TCAdefaults.table.column = value
But I have to manipulate a table which is storing a relation between categories an news records. I don't have an idea how to do that:
TCAdefaults.sys_category_record_mm.uid_foreign = 3 (-> where field tablename is "tx_news_domain_model_news" or something like that)
Thanks and thanks for reading my bad english :-)

It's much easier than you think ;-)
TYPO3 creates automaticly the relation. You have only to set the correct table of the tx_news record and the correct category field.
Here's an example for you:
TCAdefaults.tx_news_domain_model_news.categories = 1
The table of a tx_news record is "tx_news_domain_model_news" the field for the categories just named "categories". The ONE (1) is the UID of the sys_category record.
I've tested it on an 7.x TYPO3, and it works for me.

Related

Odoo 15 Find tax_ids Inside the account.move.line (Invoice) Model

Good day, hope everything's well.
I'm trying to find the value of tax_ids (Many2many field) inside the account.move.line model but i can't seems to find anything. I already access the psql of the database but i cant find tax_ids too.
I accessed that account.move.line model with ORM like this :
def _post(self, soft=True):
for move in self:
....
account_move_line = self.env['account.move.line'].search([('id', '=', int(move.id))])
print(account_move_line.tax_ids) #this find nothing
could someone please elaborate how is it possible to access id of the tax that applied to, in this case, an invoice line record?
Edit : Sometimes this ORM fetching the ID and sometimes it doesn't. But most likely it's not fetching.
I'm trying to find the value of tax_ids (Many2many field) inside the
account.move.line model but i can't seems to find anything. I already
access the psql of the database but i cant find tax_ids too.
tax_ids in account.move.line model is a Many2Many field, which is stored separately as another table in the database. This kind of relation field mostly be named something like this (main_table)_(related_table)_rel (ignore the parentheses). For example, this particular case's table is account_move_line_account_tax_rel since its main table is account_move_line and the related table for that specific field is account_tax. Inside the relation table, you will almost always find 2 fields mapping both ids together. For this case, it is going to be account_move_line_id and account_tax_id.
I accessed that account.move.line model with ORM like this :
def _post(self, soft=True):
for move in self:
....
account_move_line = self.env['account.move.line'].search([('id', '=', int(move.id))])
print(account_move_line.tax_ids) #this find nothing could someone please elaborate how is it possible to access id of the tax
that applied to, in this case, an invoice line record?
Edit : Sometimes this ORM fetching the ID and sometimes it doesn't.
But most likely it's not fetching.
Accessing a field via ORM always works as you intended if it is implemented correctly. In your code, you are searching account_move_line by id but you are trying to search it with move.id, which I assume it is account_move since you got the data sometimes. If you can access the lines that you want correctly, you will see that account_move_line.tax_ids will always give you the correct tax_ids. From what your code looks, I think you are trying to search the lines by its account_move. Therefore, your domain should be [('move_id', '=', int(move.id))] instead.

How to create inheritance in SQLite

I have to create an SQLite DB that models a survey with some ordered content; this content can be a question, an image or a simple text field (just like Google Forms). Each content doesn't have anything to do with the other, except questions which can have a list of attached images to them.
What would be the best way to model this situation? I thought about creating a "Survey" table and a "Content" table that has only an integer ID, and that same ID is then "duplicated" into each table ("Question", "Image" or "TextField"), but then I think I would have to insert both values for the Content and values for a specific content (Question, Image or TextField) every time I need to insert a new content. I don't think it would be a big problem, but if there is an way to model this better, I would like some advice.
Your approach is an example of 'table per type' as defined in this answer.
Conceptually, you're saying "there are 3 kinds of content, and the one thing they share is their relationship with a survey, as captured in the content table". You might include in that table an explicit type indicator along the ID - this will make your code a little more explicit. You may also find you need to capture meta data like "status", "date_entered" etc. which is common across subtypes.
By including a type indicator column, you make it easy to find out what the type of a content item is. So, if you want to show the summary of a question, you could do something like
select content_type, count(*)
from content
where question_id = ?
group by content_type
to show the number and type of responses.

External mapping file to match string texts

I have a table of customer feedback (verbatim) that I would like to to 're-map' to the corrected Themes and Sub-Themes based on the keywords in the verbatim.
I would like to maintain an external mapping file that can be updated at any time with the updated mapping. As an example, my external file looks like this, using food data ;)
The keywords have logical OR/AND conditions, as well as wild card * for words like work* to map to working, worked, works etc.
I would like to map a table like above to my customer feedback table based on the Category column.
As an example, if the verbatim is in Category = Fruit, and contains the words (orange OR lemon), then I'd like to update the Themes column to Citrus.
If the theme is Citrus, and verbatim also contains the words (orange OR yellow) AND colour*, then the Sub-Theme would be Colour.
Can someone please advice what the best way to achieve this? And where would be the best place to put the logic for the themes and sub-themes such that there would be minimal changes required for future updates? (if not in this external file).
Would really appreciate your help and feedback!
Thank you in advance.

Can a table field be founded and then updated with a value in mvc Controller

yeah so the question is pretty simple: Can a table field be found using and ID and then updated with a value in mvc Controller?
And before anyone gets downvote crazy... I have no example because I don't know how to do this... it's not a home work question or any other things that you down vote on this site. It's a simple question that I need an answer and a example.
I now you can use the .find to and pass the ID... to a dataset but there is nothing I can find that shows you how to edit the values in the table once you find it.
So this part I get, This will allow me to find the the id with in the dataset.
TEST_DS tEST_DS = db.TEST_DS.Find(id);
if (tEST_DS == null)
{
return HttpNotFound();
}
Also I know that you see a call to the database like This
db.TEST_TABLE.Add(TEST_DS);
I don't see an option for edit or anything like that.
The task is to update a table field, The field is a status field so when the user makes a change on the mvc create form. When they create a record I want to mark a different table's status field with a number that represents a record was created.
Did a search did not see anything.. thanks may be something mvc can't do because of it's limitations or something.
If you do answer question I will need an example of a link to an example on how to do it. Thanks!!
I was able to make this work some I will post It there for others as they might have the same issues when dealing that mvc limitations and such.
So the answer is to simply have your data table in the dbcontext that you need to edit...
The code would not post.. it asking for 4 spaces and I gave it 4 spaces and it did not work so I added a picture.
See CodeAnswer Image

renaming routes in rails 3

I'm new to this, so I'm not expecting that anyone tell me how to do it, just whether it's possible. If so, I'll continue to melt my brain with the docs.
I've been asked to change /markets/4/articles/32
to /markets/111111/articles/999999 where 111111 is in the remoteID field of the markets table and 999999 is in the remoteID field of the articles table.
The reason for this is that an external system will be creating the new records in the RoR app and inserting ITS id into the remoteID field. The next time it goes to update the record, it won't know the RoR ids without creating some kind of lookup.
From what I've seen, it can't be done. Maybe I'm just not looking hard enough?
Thanks,
Kelp
It should be possible, it probably can be changed to something like:
/markets/:market_remote_id/articles/:article_remote_id
It will then be available as params[:market_remote_id] and params[:article_remote_id] in your controller
Have a look at http://guides.rubyonrails.org/routing.html#dynamic-segments for the full story